Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WithHandlers functions are not receiving parent component's props #39

Open
Hajjiri opened this issue Jun 6, 2018 · 0 comments
Open

Comments

@Hajjiri
Copy link
Member

Hajjiri commented Jun 6, 2018

Let's say we have this code

// Render
<List data={[1, 2, 3]} />;

function List({ data, logData }) {
 return (
   <ul onClick={logData}>
     {/* can access data */}
     {data.map(row => <li>{row}</li>)}
   </ul>
 );
}

export default compose(
 withHandlers({
   logData: props => () => {
     console.log(props.data); // can’t access data
   }
 })
);

I'm expecting to receive the props from parent component into logData handler. Still, I'm only receiving component props.

Adding withObservable((app, props$) => props$) before withHandlers fixes it.

Is that the expected behaviour? If so, do we have another way using frint-props to access the parent props.

After some research it seems that the handler functions receive 3 params. App, props, parentProps$.
parentProps$ has access to data as per the above example. Still, as a developer I expect the compose function will compose into the handlers the component, and parent component props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant