Skip to content

Commit 50cdeed

Browse files
committed
fix: remove additional reducers
1 parent 659e460 commit 50cdeed

File tree

2 files changed

+16
-60
lines changed

2 files changed

+16
-60
lines changed

src/store/configureStore.ts

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {combineReducers, configureStore as configureReduxStore} from '@reduxjs/toolkit';
1+
import {configureStore as configureReduxStore} from '@reduxjs/toolkit';
22
import type {Action, Dispatch, Middleware, Reducer, UnknownAction} from '@reduxjs/toolkit';
33
import type {History} from 'history';
44
import {createBrowserHistory} from 'history';
@@ -7,7 +7,7 @@ import {listenForHistoryChange} from 'redux-location-state';
77
import {YdbEmbeddedAPI} from '../services/api';
88

99
import {getUrlData} from './getUrlData';
10-
import {rootReducer} from './reducers';
10+
import rootReducer from './reducers';
1111
import {api as storeApi} from './reducers/api';
1212
import {syncUserSettingsFromLS} from './reducers/settings/settings';
1313
import {UPDATE_REF} from './reducers/tooltip';
@@ -54,70 +54,18 @@ export const codeAssistBackend = window.code_assist_backend;
5454

5555
const isSingleClusterMode = `${metaBackend}` === 'undefined';
5656

57-
interface BaseStoreOptions {
58-
singleClusterMode?: boolean;
59-
api?: YdbEmbeddedAPI;
60-
}
61-
62-
interface StoreOptionsWithCustomRootReducer extends BaseStoreOptions {
63-
/**
64-
* Custom root reducer that completely replaces the default rootReducer.
65-
* ⚠️ Cannot be used together with additionalReducers
66-
*/
67-
aRootReducer: Reducer;
68-
/**
69-
* @deprecated When using aRootReducer, additionalReducers cannot be used
70-
*/
71-
additionalReducers?: undefined;
72-
}
73-
74-
interface StoreOptionsWithAdditionalReducers extends BaseStoreOptions {
75-
/**
76-
* @deprecated When using additionalReducers, aRootReducer cannot be used
77-
*/
78-
aRootReducer?: undefined;
79-
/**
80-
* Additional reducers to be merged with the default rootReducer.
81-
* ⚠️ Cannot be used together with aRootReducer
82-
*/
83-
additionalReducers: Record<string, Reducer>;
84-
}
85-
86-
interface StoreOptionsDefault extends BaseStoreOptions {
87-
aRootReducer?: undefined;
88-
additionalReducers?: undefined;
89-
}
90-
91-
export type ConfigureStoreOptions =
92-
| StoreOptionsWithCustomRootReducer
93-
| StoreOptionsWithAdditionalReducers
94-
| StoreOptionsDefault;
95-
96-
export function configureStore(options: ConfigureStoreOptions = {}) {
97-
const {
98-
aRootReducer,
99-
singleClusterMode = isSingleClusterMode,
100-
api = new YdbEmbeddedAPI({webVersion, withCredentials: !customBackend}),
101-
additionalReducers = {},
102-
} = options;
103-
57+
export function configureStore({
58+
aRootReducer = rootReducer,
59+
singleClusterMode = isSingleClusterMode,
60+
api = new YdbEmbeddedAPI({webVersion, withCredentials: !customBackend}),
61+
} = {}) {
10462
({backend, basename, clusterName} = getUrlData({
10563
singleClusterMode,
10664
customBackend,
10765
}));
10866
const history = createBrowserHistory({basename});
109-
let finalReducer: Reducer;
110-
111-
if (aRootReducer) {
112-
finalReducer = aRootReducer;
113-
} else {
114-
finalReducer = combineReducers({
115-
...rootReducer,
116-
...additionalReducers,
117-
});
118-
}
11967

120-
const store = _configureStore(finalReducer, history, {singleClusterMode}, [
68+
const store = _configureStore(aRootReducer, history, {singleClusterMode}, [
12169
storeApi.middleware,
12270
]);
12371
listenForHistoryChange(store, history);

src/store/reducers/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {combineReducers} from '@reduxjs/toolkit';
2+
13
import {api} from './api';
24
import authentication from './authentication/authentication';
35
import cluster from './cluster/cluster';
@@ -37,3 +39,9 @@ export const rootReducer = {
3739
fullscreen,
3840
clusters,
3941
};
42+
43+
const combinedReducer = combineReducers({
44+
...rootReducer,
45+
});
46+
47+
export default combinedReducer;

0 commit comments

Comments
 (0)