Reputation: 1061
I want to compose (recompose) a React component with recompose.pure and an other hoc.
In what order should I do this ?
What is the criterion for deciding this ?
import { compose, pure } from "recompose";
const MyComp = ({}) => (<div>test</div>);
export default compose(pure, anOtherHoc)(MyComp);
Upvotes: 3
Views: 606
Reputation: 20236
Each argument passed to the compose function creates another wrapper around the component you are enhancing.
So it really depends on anOtherHoc
– is that a pure component, i.e. does it only have to be updated when the props that are passed to it have changed?
If yes, put pure
first, and it will wrap anOtherHoc
, which in turn wraps MyComp
.
If not, put it after anotherHoc
, then MyComp
will wrap pure
, which will wrap MyComp
.
Upvotes: 3