There's nothing preventing you from choosing an end date that’s before the start date, which makes no sense. There's no guard for a title or description that is too long. Using useReducer, we could transform the above code, to just this: i The hook helps you control transformations from state A to state B.

6m read timeFrom dev.to
Post cover image
Table of contents
There is a better alternative to useStateYou can use useReducer virtually anywhere you’d use useState(Optionally) Redux-ify thingsSharing reducersThe common pitfall(Optional) Common pitfall solution: ImmerSo when should I use useState vs useReducer ?Thank you, DavidAbout Me
20 Comments

Sort: