DEV Community

Discussion on: prevState with useReducer hook in React.

lyrod profile image

I think, creating the function outside of the component (for example: in a folder "hooks") is better.

Thread Thread
ivanjeremic profile image
Ivan Jeremic Author

Yea I wanted somehow to include the code for the hook here so people can see it, but maybe I should have put it outside the Provider which would be the same effect as in a separate folder. Thanks