3 ms·
I haven't seen that usage for higher-order components before. This is the pattern I've been following: function decorate (Component) { let HigherOrde
by mikewhy 11y ago
I haven't seen that usage for higher-order components before. This is the pattern I've been following:
function decorate (Component) {
let HigherOrderComponent = React.createClass({
render () {
return <Component {...this.props} />
}
})
return HigherOrderComponent
}
as explained here: https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750 https://medium.com/@dan_abramov/mixins-are-dead-long-live-hi...
- HeyImAlex 11y agoThey are the same I think, only one has extra parameters. At least in Python, @fn(...args) evaluates the function first and uses the result as a decorator. The guy who wrote the blog post you mention actually uses the parent's pattern in react-dnd.