7 Matching Annotations
- Oct 2020
-
github.com github.com
-
Comparison to useReducer
-
This library exports a single React Hook, useMethods, which has all the power of useReducer but none of the ceremony that comes with actions and dispatchers.
-
-
-
A first step would be to dispatch actions and update state via a reducer, something along the lines of useReducer in React.
Tags
Annotators
URL
-
- Oct 2019
-
gist.github.com gist.github.com
- Aug 2019
-
www.freecodecamp.org www.freecodecamp.org
-
I’m here to convince you that when wrapped in a 4 line custom hook, useState can be just as powerful as, if not more powerful than, useReducer when managing complex state.
-
-
www.robinwieruch.de www.robinwieruch.de
-
So far, we have used various state hooks to manage our data fetching state for the data, loading and error state. However, somehow all these states, managed with their own state hook, belong together because they care about the same cause. As you can see, they are all used within the data fetching function. A good indicator that they belong together is that they are used one after another (e.g. setIsError, setIsLoading). Let's combine all three of them with a Reducer Hook instead.
Tags
Annotators
URL
-
-