ummahusla / edvins-io

My digital garden
https://edvins.io
MIT License
5 stars 2 forks source link

how-to-efficiently-refactor-use-state-to-use-reducer-in-react #31

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

How to efficiently refactor useState to useReducer in React | Edvins Antonovs

Learn how to improve the performance and maintainability of your React code by refactoring useState to useReducer. My step-by-step guide includes code examples and best practices to help you make the switch.

https://edvins.io/how-to-efficiently-refactor-use-state-to-use-reducer-in-react

Cheuktingchan commented 1 year ago

Interesting! So given the advantages and disadvantages of useReducer will you use useReducer from the get go rather than useState, or will it only be worth using during refactoring?

ummahusla commented 1 year ago

@Cheuktingchan I will reply with a quote of my friend which approach I'm not adopted:

I think main point from me is that if one state change causes an effect that changes another bit of state, then always use a reducer instead.