Skip to content

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

Description

@Hajjiri

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions