Created
March 31, 2016 18:13
-
-
Save slyder/2740362ba52739d4ab3c0e856e58c802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use(async function (req, res, next) { | |
try { | |
const memoryHistory = createMemoryHistory(req.url); | |
const store = configureStore(memoryHistory); | |
const history = syncHistoryWithStore(memoryHistory, store); | |
const html = await new Promise((resolve, reject) => { | |
// match the routes to the url | |
match({history, routes, location: req.url }, (err, redirect, renderProps) => { | |
if (err) reject(err); | |
console.log('@@@store 111', store.getState().session.profile.id); | |
const appHtml = renderToString( | |
<Provider store={store}> | |
<RouterContext {...renderProps} /> | |
</Provider> | |
); | |
console.log('@@@store 222', store.getState().session.profile.id); | |
const appHtml2 = renderToString( | |
<Provider store={store}> | |
<RouterContext {...renderProps} /> | |
</Provider> | |
); | |
resolve(appHtml2); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment