An easier way to handle LOADING, ERROR and SUCCESS states in Redux
Hey there ππ½,
Firstly, sorry I couldn't come up with a more catchy name π©. Believe me, I tried.
We know that the boilerplate for Redux can be a little bit, yunno, annoying... And if you've got lots of states to manage, for maybe a huge awesome ap...
blog.adedaniel.com15 min read
Hi, I'm a Redux maintainer.
You can simplify this code considerably by using our official Redux Toolkit package. It includes utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once.
It also has a
createAsyncThunkAPI that automatically dispatchespending/fulfilled/rejectedactions based on a promise, andcreateSlicenow offers "matcher" reducers that match against arbitrary actions (such as "any action whose type ends with/pending").We specifically recommend using RTK as the default way to write Redux logic, and I just published a brand-new "Redux Essentials" core docs tutorial, which teaches beginners "how to use Redux, the right way", using our latest recommended tools and practices. I'd encourage you to check it out:
redux.js.org/tutorials/essentials/part-1-overviewβ¦