if my HOC is setting state ,do I need to change my Container component to always assume that a function is being passed in for getdata and updatedata?

I have a Container Component that I want to make more reusable, I've refactored my code as much as possible, but I have two parts of the component that I want to be able to change dynamically, which I think a HOC will help
The two parts are a function to get data and a function to update data
From what I understand from reading the docs I can use a HOC to wrap the component and pass in functions that can be reused
 
My question is, if my HOC is setting state but my container component is also setting state, do I need to change my Container component to always assume that a function is being passed in for getdata and updatedata?
You already invited:

Ali

Upvotes from:

I think you should do that if they are changing the state in different ways

Carter

Upvotes from:

the hoc uses the same pattern as regular components, passing state from parent to child. Parent is hoc in this case. So if you pass state from hoc to wrapped component and change it, you should reflect its change in hoc. If your wrapped component just uses hoc state as initial and has local component state as well, you change state only in component. Hope it makes sense :)

If you wanna answer this question please Login or Register