Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit bdd8702

Browse files
committed
fix: Add a new API for how to register the redux store to fix an issue with dispatching from reactotron into the middleware.
1 parent 00de295 commit bdd8702

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/enhancer.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function createEnhancer(
99
pluginConfig: PluginConfig,
1010
handleStoreCreation: () => void
1111
) {
12-
return () => createStore => (reducer, ...args) => {
12+
return (skipSettingStore = false) => createStore => (reducer, ...args) => {
1313
const originalStore = createStore(
1414
reactotronReducer(reducer, pluginConfig.restoreActionType),
1515
...args
@@ -18,9 +18,11 @@ export default function createEnhancer(
1818
...originalStore,
1919
dispatch: createCustomDispatch(reactotron, originalStore, pluginConfig),
2020
}
21-
reactotron.reduxStore = store
2221

23-
handleStoreCreation()
22+
if (!skipSettingStore) {
23+
reactotron.reduxStore = store
24+
handleStoreCreation()
25+
}
2426

2527
return store
2628
}

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ function reactotronRedux(pluginConfig: PluginConfig = {}) {
2828
onCommand: createCommandHander(reactotron, mergedPluginConfig, onReduxStoreCreation),
2929
features: {
3030
createEnhancer: createEnhancer(reactotron, mergedPluginConfig, handleStoreCreation),
31+
setReduxStore: store => {
32+
reactotron.reduxStore = store
33+
handleStoreCreation()
34+
},
3135
reportReduxAction: createSendAction(reactotron),
3236
},
3337
}
@@ -44,6 +48,11 @@ declare module "reactotron-core-client" {
4448
/**
4549
* Enhancer creator
4650
*/
47-
createEnhancer?: () => StoreEnhancer
51+
createEnhancer?: (skipSettingStore?: boolean) => StoreEnhancer
52+
53+
/**
54+
* Store setter
55+
*/
56+
setReduxStore?: (store: any) => void
4857
}
4958
}

0 commit comments

Comments
 (0)