A
A
Alex Polyakh2018-07-18 13:01:09
JavaScript
Alex Polyakh, 2018-07-18 13:01:09

Classic currying, replace with {compose} function from Ramda.js to use ReactJS HOC?

The important point is that the function works from top to bottom, that is, from right to left, realizing this, I can’t use it instead of this entry:
export default HOC('props1')('props2')(ChildHoc)
Here is a complete example with all dependencies :
https://stackblitz.com/edit/hoccomponent?file=chil...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-07-18
@PolyakhAleksandr

You apparently misunderstood something somewhere. Currying with compose cannot be replaced.
It is used to get rid of nesting:

// without compose
withLog(withRouter(connect(mapStateToProps)(withDropdown(props)(Component))));

// with compose
compose(
  withLog,
  withRouter,
  connect(mapStateToProps),
  withDropdown(props),
)(Component);

Also, using compose allows you to pass functions dynamically:
The implementation of compose is in the redux package.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question