Skip to content

Commit 174d1b3

Browse files
authored
Fix redux "Store does not have a valid reducer" error (#80)
Related to #71 . When the registry was added, it was first creating the store with no reducers, which caused this error to be printed out. Now, add reducers to the registry before creating the store to avoid the error. Note reducers can still be added to the registry after that fact.
1 parent 194acce commit 174d1b3

File tree

2 files changed

+10
-75
lines changed

2 files changed

+10
-75
lines changed

packages/redux/src/index.js

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,5 @@
1-
import reducers from './reducers';
2-
import reducerRegistry from './reducerRegistry';
3-
4-
// TODO #70: Separate all reducers into their respective modules, register from there
5-
Object.entries(reducers).map(([name, reducer]) =>
6-
reducerRegistry.register(name, reducer)
7-
);
8-
9-
export {
10-
getActiveTool,
11-
getClosedPanelsForDashboard,
12-
getColumnSelectionValidatorForDashboard,
13-
getColumnsForDashboard,
14-
getCommandHistoryStorage,
15-
getConsoleCreatorSettingsForDashboard,
16-
getControllerConfiguration,
17-
getDashboardClosedPanels,
18-
getDashboardColumnSelectionValidators,
19-
getDashboardColumns,
20-
getDashboardConsoleCreatorSettings,
21-
getDashboardInputFilters,
22-
getDashboardIsolatedLinkerPanelIds,
23-
getDashboardLinks,
24-
getDashboardOpenedPanelMaps,
25-
getDashboardPanelTableMaps,
26-
getDefaultDateTimeFormat,
27-
getDisableMoveConfirmation,
28-
getDraftManager,
29-
getFormatter,
30-
getInputFiltersForDashboard,
31-
getIsLoggedIn,
32-
getIsolatedLinkerPanelIdForDashboard,
33-
getLinksForDashboard,
34-
getOpenedPanelMapForDashboard,
35-
getServerConfigValues,
36-
getSettings,
37-
getShowSystemBadge,
38-
getShowTSeparator,
39-
getShowTimeZone,
40-
getStorage,
41-
getTableMapForDashboard,
42-
getTimeZone,
43-
getUser,
44-
getUserGroups,
45-
getUserName,
46-
getWorkspace,
47-
getWorkspaceStorage,
48-
} from './selectors';
49-
export {
50-
addDashboardLinks,
51-
deleteDashboardLinks,
52-
saveSettings,
53-
saveWorkspace,
54-
setActiveTool,
55-
setCommandHistoryStorage,
56-
setControllerConfiguration,
57-
setDashboardClosedPanels,
58-
setDashboardColumnSelectionValidator,
59-
setDashboardColumns,
60-
setDashboardConsoleCreatorSettings,
61-
setDashboardInputFilters,
62-
setDashboardIsolatedLinkerPanelId,
63-
setDashboardLinks,
64-
setDashboardOpenedPanelMap,
65-
setDashboardPanelTableMap,
66-
setDraftManager,
67-
setIsLoggedIn,
68-
setServerConfigValues,
69-
setUser,
70-
setWorkspace,
71-
setWorkspaceStorage,
72-
updateWorkspaceData,
73-
} from './actions';
1+
export * from './selectors';
2+
export * from './actions';
743
export { default as reducers } from './reducers';
754
export { default as reducerRegistry } from './reducerRegistry';
765
export { default as store } from './store';

packages/redux/src/store.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { applyMiddleware, createStore, compose, combineReducers } from 'redux';
22
import rootMiddleware from './middleware';
3+
import reducers from './reducers';
34
import reducerRegistry from './reducerRegistry';
45

6+
// TODO #70: Separate all reducers into their respective modules, register from there
7+
Object.entries(reducers).map(([name, reducer]) =>
8+
reducerRegistry.register(name, reducer)
9+
);
10+
511
/* eslint-disable-next-line no-underscore-dangle */
612
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
713

@@ -10,8 +16,8 @@ const store = createStore(
1016
composeEnhancers(applyMiddleware(...rootMiddleware))
1117
);
1218

13-
reducerRegistry.setListener(reducers => {
14-
store.replaceReducer(combineReducers(reducers));
19+
reducerRegistry.setListener(newReducers => {
20+
store.replaceReducer(combineReducers(newReducers));
1521
});
1622

1723
export default store;

0 commit comments

Comments
 (0)