C
C
cester2018-06-13 09:57:35
React
cester, 2018-06-13 09:57:35

How to implement via HOC, react?

Good afternoon! Can you please tell me how to implement this component through HOC?

const SortableItem = SortableElement(({value}) => (
 <ElementItem value={value}/>
));

You just need the `SortableElement` component to accept all the props.
That is, it is necessary that in 'ElementItem' it was somehow like this and everything worked. I would be grateful for the help!
export default hocComponent(ElementItem)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-06-13
@cester

Without options:

const withSort = WrappedComponent => props => {
  return WrappedComponent ? <WrappedComponent {...props} /> : null;
});

Usage: With options:
const withSort = (...params) => WrappedComponent => props => {
  // params usage
  return WrappedComponent ? <WrappedComponent {...props} /> : null;
});

Usage:
export default withSort(param1, param2)(Component);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question