DEV Community

Creating stores using React context, hooks, and Immer

Ferdy Budhidharma on January 19, 2019

When creating any medium-to-large React applications, it's useful to have a store to contain your core application data. We don't want to be loadin...
Collapse
 
yamessays profile image
James Cameron

Good article, but it's a lot of "here's the code" and not much explanation to the reasoning.

Collapse
 
sergeyt profile image
Sergey Todyshev

Here is a followup on this post

Collapse
 
sergeyt profile image
Sergey Todyshev

Useful pattern to me. Thank you!

Collapse
 
favreleandro profile image
Leandro Favre • Edited

Hi, great article! How can I see the previous state? I understand you use immer to make an immutable state.

Collapse
 
ferdaber profile image
Ferdy Budhidharma

You unfortunately can't see the previous state since you're not using Redux. Two options: transform your store so that it keeps a history stack of previous states, or use hook up all of this to a Redux store, and have it publish out the state to Redux DevTools.

Collapse
 
obiwarn profile image
Sebastian Obentheuer

Whoa...this is very elegant. I love it. Thank you!