I feel that Redux articles at this one in particular aren't showing what Redux should be used for.
For the provided example, as well as almost any React project, React's useReducer would be a much better option:
And if you need to pass the state along the app, add a React context to the mix.
So why should one add Redux to the project if React already comes shipped with similar tools?
You definitely don't need redux for a counter app but once your app starts growing and getting more complex you might end up implementing redux yourself.
That has been in discussion in years. It might happen, but I would not make any bets on how the final Api will look or write code anticipating it today.
Not really, in most cases you're better off with scoped states for a complex app. It makes it much easier to test and maintain.
I think you really need Redux when you need a state that is mutated from a lot of places, so that it makes sense to make it global, or if you want to track the global state of the whole app for the time travel.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I feel that Redux articles at this one in particular aren't showing what Redux should be used for.
For the provided example, as well as almost any React project, React's
useReducerwould be a much better option:And if you need to pass the state along the app, add a React context to the mix.
So why should one add Redux to the project if React already comes shipped with similar tools?
You definitely don't need redux for a counter app but once your app starts growing and getting more complex you might end up implementing redux yourself.
React is soon getting a useSelector hook in core which makes redux useless.
That has been in discussion in years. It might happen, but I would not make any bets on how the final Api will look or write code anticipating it today.
Until then Valtio is the cleanest solution out there no competition.
Not really, in most cases you're better off with scoped states for a complex app. It makes it much easier to test and maintain.
I think you really need Redux when you need a state that is mutated from a lot of places, so that it makes sense to make it global, or if you want to track the global state of the whole app for the time travel.