You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, sorry for the long wait with the answer... and it might not be what you want to hear :/
Unfortunately this is an approach that I don't recommend. When initialising the store, kea does many things that are hard to replicate in your own code, including for example any setup that the various plugins might want to run.
It's often easier to convert your own store setup to the format expected by resetContext({ createStore: { ... } }). It might even help clean up the otherwise relatively messy default redux store creation code. See here for the API of createStore.
However, if you really really want to do this, basically the minimum you need is to run:
// still, I don't recommend itimport{resetContext,keaReducer}from'kea'functionrunPlugins(key, ...args){const{ plugins }=getContext()plugins&&plugins.events[key]&&plugins.events[key].forEach(p=>p(...args))}constoptions={createStore: false}constcreateStoreOptions={}constcontext=resetContext(options)runPlugins('beforeReduxStore',createStoreOptions)context.store=storerunPlugins('afterReduxStore',createStoreOptions,store)
When you create a store you will also need to pass it reducers that will contain the data kea will use.
import{keaReducer}from'kea'constreducers={// your own reducers herekea: keaReducer('kea'),scenes: keaReducer('scenes'),// other keaReducers if needed}conststore=finalCreateStore(combineReducers(reducers), ...)
NB, I didn't test this code, but just extracted it from the store setup. Read the original source in case something is broken.
Also, it's possible that instead of Redux's combineReducers you will need to run combineKeaReducers, but that's also not exported publicly and it might be easier to just copy/paste the code to your app.
For an existing application that have a store created with redux/createStore. How should that store be integrated into kea?
The text was updated successfully, but these errors were encountered: