frintjs / frintjs/frint-props

WithHandlers functions are not receiving parent component's props

Open
#39 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Let's say we have this code

```
// Render
;

function List({ data, logData }) {
return (


    {/* can access data */}
    {data.map(row =>
  • {row}
  • )}

);
}

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.