Re:Frustrations with React Hooks
by ssalka on Tuesday September 10, 2019 @03:15PM
(#20932273)
My personal opinion is that state should be contained in some sort of class or data structure, separate from functional architectures where the notion of state is generally avoided. So my usual suggestion would be to use either a class component (or redux or insert favorite state mgmt solution here) for your state, and then inject the state as props to your function components
[ Parent
| on HN ]
Re:Frustrations with React Hooks
by cercatrova on Thursday September 12, 2019 @02:10AM
(#20948516)
That's fine, you can use React's Context API and reducers just like Redux, for which the useContext and useReducer hooks exist. Then it's just like Redux, inject a Provider and Consumer and you're good to go.