DEV Community

Discussion on: useReducer instead of useState while calling APIs!

Collapse
 
antontsvil profile image
Anton T

To help understand hooks, you might wanna look up array destructuring (similar to object destructuring). In short - you can use whatever names you like when destructuring an array, so just use different names for your second useReducer hook!

const [state, dispatch] = useReducer(userDetailsReducer, initialState);
const [likeState, likesDispatch] = useReducer(userLikesReducer, initialLikesState);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jharteaga profile image
Jose Arteaga

Thanks @antontsvil ! That helped me as well to understand that it is possible! great example!

Some comments have been hidden by the post's author - find out more