This is started as personal joke: using svelte/store as a hook instead of react-redux
You can check the svelte/store hooks in this file. A typescript implementation is also available in this gist
I could use the store without using a reducer, but to be fair I choose to use the reducer
pattern. The useReducerWithStore
hook is similar to react's userReducer
, but takes
the store instead of the initial state (to share the global value).
The rest of the code need only small changes, and only in the containers
folder as well
as removing the react-redux provider from the index.js
dispatchAll(dispatchArr, action)
helpermapStateToProps
result has changed,
so react can trigger a re-render. This happens for every mapStateToProps
, on every dispatch
call.
By using the combination of useState
, useEffect
and the subscription model, we now need
only the necessary render calls, without any comparisons.This grows linearly with both the number of reducers and connected components!!
This is the result from the build log, as you can see:
This is the result of using the source-map-explorer
tool, as you can see: