lifecycle({
componentDidMount: () => {
// How do i get prop here?
}
})(Component)
this.props
it seems this doesn't work when using arrow functions?
Is it working with alternative syntax for object methods? E.g.
lifecycle({
componentDidMount() {
this.props;
}
})(Component)
EDIT: I've done a test locally, and it ought to work with the above syntax.
The alternative syntax worked for me, not the arrow fn. I'll test again but I'm pretty sure syntax was all I changed for it to work. Using es2015 and stage 2 in my babel config
you could try @hocs/with-lifecycle, works with arrow functions as well and doesn't depend on this:
withLifecycle(
onDidMount: (props) => // ...
)
@deepsweet Any way to integrate that implementation into this project?
No way. Use search here for why.
No way. Use search here for why.
The behavior in a arrow function is expected, because arrow functions have no binding of this.
Most helpful comment
The behavior in a arrow function is expected, because arrow functions have no binding of
this.