Interop with existing redux store
See original GitHub issueHi there, great library!
I read through the docs and found https://easy-peasy.now.sh/docs/recipes/usage-with-react-redux.html but the given example replaces the top level Provider’s store with a new easy-peasy store.
We’ve got an large existing redux store, and wanted to begin migrating to easy-peasy by having easy-peasy control a subtree of that store. Is that possible? Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Interop with an existing React Redux application
This recipe will guide you through the process of integrating Easy Peasy into your existing React Redux application. It is possible to slowly ......
Read more >Connecting React and Redux - Manning Publications
To connect Redux with React, we'll use the React bindings from the react-redux package. Redux provides only the means to configure a store....
Read more >Using a Redux store in your React.js application
In a store based implementation the 'store' takes over the handling of data that can change. All the react components then link to...
Read more >Step-By-Step: How to Add Redux to a React App | Codementor
Step 5: Select and Transform State from Redux Store. Let's use our Container component to select the state and optionally, transform it. src/ ......
Read more >How to connect Redux containers in my library to the store ...
I am creating a npm module that uses Redux for state management. My module will be a library that is re-used across a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I have successfully integrated Easy-Peasy (EP) with ordinary Redux actions and reducers. The method I used is a reducerEnhancer, which is a store-config option in EP. This helper (below) runs every action through both the ordinary root-reducer (
legacyRootReducer) and the EP root-reducer that’s passed-in (epRootReducer) …Demonstration Repository
The Easy-Peasy Test App I created (using CRA) is on GitHub. If you want to do your own testing, pull it and then run
npm installandnpm start. Use Redux Dev-Tools to see what’s happening when you click the test-buttons. https://github.com/allpro/easy-peasy-testercombineReducers Issues
The ordinary rootReducer is created with the combineReducers helper. This can cause problems because it ignores/deletes any top-level ‘key’ that does not exist in its own configuration. This means keys that exist only in EP models get deleted! combineReducers logs these keys in the console so it’s easy to debug.
The simple solution is to add dummy-keys for domains/keys that exist only in EP. This prevents combineReducers from deleting them. Here is what that looks like in my test app…
Overlapping Functionality
I tested having the same data-keys, thunks and actions specified in both EP and ordinary Redux. This works fine. Since the two instances use different action-names (by default), only one reducer is run for each action, so there is no duplication. However, EP can dispatch an action-name to be handled by an ordinary reducer, and visa-versa. This means the two systems can inter-operate easily, and code can be transitioned to EP one action or reducer at a time.
Middleware Integration
EP already adds
redux-thunkmiddleware, so if you are using this you don’t even need to import it anymore!Other middleware can be added, but I didn’t need to - yet.My next test will be with Redux Saga middleware because that’s what I need to integrate with. I’m hopeful that will not be a problem. Stay tuned!UPDATE 2019-07-11
I’m now using this pattern in a production app that uses multiple middleware, including:
All middleware works as normal - the existing Redux code requires no modifications. The two systems work fine together.
I did need to modify the old code that hot-loaded the ‘root-reducer’ in development. This was simple though - see the separate hot-loading issues or the docs for details on this.
Thank you both!