Skip to content

Commit

Permalink
[FEATURE] Added hydrate support for advanced Rendertron Setup
Browse files Browse the repository at this point in the history
 related pull request: GoogleChrome/rendertron#654
  • Loading branch information
lewisvoncken committed Mar 29, 2021
1 parent 9d5e9e9 commit 752173f
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/venia-concept/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,26 @@ const apolloLink = ApolloLink.from([
Adapter.apolloLink(apiBase)
]);

ReactDOM.render(
<Adapter apiBase={apiBase} apollo={{ link: apolloLink }} store={store}>
<AppContextProvider>
<App />
</AppContextProvider>
</Adapter>,
document.getElementById('root')
);
const rootElement = document.getElementById('root');
if (rootElement.hasChildNodes()) {
ReactDOM.hydrate(
<Adapter apiBase={apiBase} apollo={{ link: apolloLink }} store={store}>
<AppContextProvider>
<App />
</AppContextProvider>
</Adapter>,
rootElement
);
} else {
ReactDOM.render(
<Adapter apiBase={apiBase} apollo={{ link: apolloLink }} store={store}>
<AppContextProvider>
<App />
</AppContextProvider>
</Adapter>,
rootElement
);
}

registerSW();

Expand Down

0 comments on commit 752173f

Please sign in to comment.