gbaldeck
02/03/2020, 9:07 PMZachary Grafton
02/03/2020, 9:38 PMval
and assigning a lambda. However, I would recommend looking at hooks and the useReducer
hook combined with the useContext
hook, especially if you are thinking about using redux in your project at some point in time.gbaldeck
02/03/2020, 10:05 PMgbaldeck
02/03/2020, 10:08 PMuseCallback
hook was created exactly for the purpose I am describing. https://reactjs.org/docs/hooks-reference.html#usecallbackZachary Grafton
02/04/2020, 2:29 PMuseReducer
it returns a dispatch function which you can then use to dispatch actions that can process the state and generate a new state. This essentially eliminates the traditional callback mechanism and it doesn't need to generate lambdas. I've been meaning to write up a blog post explaining it from the Kotlin perspective, time is high demand around here though. The useEffect
hook is also extremely useful for dispatching HTTP requests, which you can then use the dispatcher from the useReducer
hook to update your component's state. Also, keep in mind you can even write your own hooks.Zachary Grafton
02/04/2020, 2:31 PM