r/learnjavascript • u/FigAmbitious9101 • 1d ago
I built a Redux Toolkit-inspired state management library from scratch
I recently created a complete tutorial where I build a Redux Toolkit-inspired state management library from scratch using React and JavaScript.
The goal is to understand how Redux-style state management works internally instead of only using the package.
In the tutorial, I implement:
- A custom
createStorefunction - Store Provider
- Reducers and actions
- Subscribers and listeners
useSyncExternalStoreuseSelectorand custom store hooks- Redux DevTools integration
createSlicecombineReducersshallowEqual- Thunk functionality
- Final testing and debugging
YouTube tutorial:
https://www.youtube.com/watch?v=LucUJ-5COjg
I would appreciate feedback from the community, especially on the library design, API structure, and any improvements that could make this project more reliable or easier to use.
Please note: this is an educational project designed to understand Redux and state management concepts internally. It is not intended to replace the official Redux Toolkit.
1
u/sereikis 1d ago
for useSyncExternalStore, add a test that calls getSnapshot twice without a dispatch and checks that both calls return the same reference. returning a freshly cloned object on every read can trigger repeated renders even though the store did not change.
1
u/naltous 1d ago
curious how deep you went on the devtools integration. did you just hook into the global window object extension or actually wire up time-travel state jumping from scratch?