Skip to content

Commit

Permalink
Use the same root redux reducer for both server-side and client-side (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
azangru authored Jul 11, 2023
1 parent 62d8217 commit 23ec8c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 0 additions & 12 deletions src/root/rootReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,4 @@ const createRootReducer = () =>
[restApiSlice.reducerPath]: restApiSlice.reducer
});

export const createServerSideRootReducer = () =>
combineReducers({
global,
pageMeta,
speciesSelector,
entityViewer,
genome,
blast,
[graphqlApiSlice.reducerPath]: graphqlApiSlice.reducer,
[restApiSlice.reducerPath]: restApiSlice.reducer
});

export default createRootReducer;
6 changes: 4 additions & 2 deletions src/server/serverSideReduxStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import { configureStore } from '@reduxjs/toolkit';
import graphqlApiSlice from 'src/shared/state/api-slices/graphqlApiSlice';
import restApiSlice from 'src/shared/state/api-slices/restSlice';

import { createServerSideRootReducer } from 'src/root/rootReducer';
import createRootReducer from 'src/root/rootReducer';

// compared to the client-side store, the server-side store does not need
// the middleware for redux-observable
const middleware = [graphqlApiSlice.middleware, restApiSlice.middleware];

export const getServerSideReduxStore = () => {
return configureStore({
reducer: createServerSideRootReducer(),
reducer: createRootReducer(),
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(middleware)
});
Expand Down

0 comments on commit 23ec8c6

Please sign in to comment.