Skip to content

Commit

Permalink
minor fix for initial state handling (#1522)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Feb 6, 2020
1 parent 20000e2 commit 18dad28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions packages/subapp-redux/src/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function createSharedStore(initialState, info, storeContainer) {
if (store) {
// TODO: redux doesn't have a way to set initial state
// after store's created? What can we do about this?
replaceReducer(info.reduxReducers, info);
replaceReducer(info.reduxReducers, info, storeContainer);
} else {
reducerContainer = newReducerContainer();
store = createStore(
Expand All @@ -101,10 +101,11 @@ function createSharedStore(initialState, info, storeContainer) {
);
store[originalReplaceReducerSym] = store.replaceReducer;
//
// TODO: monkey patching store is bad
// since this is share store, reducers must be replaced
// as object of named reducers also, but patching an API
// that alters argument type is worst
// TODO: better handling of a replaceReducer that takes extra params
//
// Since this is share store, reducers must be replaced
// as object of named reducers also.
//
// Maybe create a proxy store object, one for each sub-app
//
// NOTE: It's only on SSR that we need to share store within the
Expand Down
4 changes: 2 additions & 2 deletions packages/subapp-web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export function loadSubApp(info, renderStart) {

if (!instance._prepared) {
if (subApp.info.prepare) {
instance._prepared = subApp.info.prepare(subApp.info, instance);
instance._prepared = subApp.info.prepare(subApp.info, instance, options);
} else {
instance._prepared = {};
instance._prepared = options.initialState || {};
}
}

Expand Down

0 comments on commit 18dad28

Please sign in to comment.