Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fix for initial state handling #1522

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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