Skip to content

Commit

Permalink
Add option for reduxStoreReady for subapp pbundle (#1507)
Browse files Browse the repository at this point in the history
* Add option for reduxStoreReady for subapp pbundle

* Do not pass all of "this": only the store

* Do not use preact hydrate
  • Loading branch information
christianlent authored and jchip committed Jan 23, 2020
1 parent 93206c5 commit 55ebfb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
4 changes: 4 additions & 0 deletions packages/subapp-pbundle/lib/framework-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class FrameworkLib {
this.store,
`redux subapp ${subApp.name} didn't provide store, reduxCreateStore, or reducers`
);
const reduxStoreReady = subAppServer.reduxStoreReady || subApp.reduxStoreReady;
if (reduxStoreReady) {
await reduxStoreReady({store: this.store});
}
if (options.serverSideRendering === true) {
assert(Provider, "subapp-web: react-redux Provider not available");
// finally render the element with Redux Provider and the store created
Expand Down
21 changes: 6 additions & 15 deletions packages/subapp-pbundle/src/redux-bundler.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@ export function reduxRenderStart(options) {
const store = options._store || options.reduxCreateStore(options.initialState);
const { Component } = options;

if (options.serverSideRendering) {
hydrate(
<Provider store={store}>
<Component />
</Provider>,
options.element
);
} else {
render(
<Provider store={store}>
<Component />
</Provider>,
options.element
);
}
render(
<Provider store={store}>
<Component />
</Provider>,
options.element
);

return store;
}
Expand Down

0 comments on commit 55ebfb0

Please sign in to comment.