Last active
August 10, 2017 10:13
-
-
Save faceyspacey/359dcfe3ade870ffdc16011111b771fc 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
const { ...theUsual, thunk, initialDispatch } = connectRoutes( | |
history, | |
routesMap, { | |
...options, | |
initialDispatch: isServer ? false : true | |
} | |
) | |
... | |
return { store, thunk, initialDispatch } | |
import { fetchUser } from '../src/actions/async' | |
export default async (req, res) => { | |
const history = createHistory({ initialEntries: [req.path] }) | |
const { store, thunk, initialDispatch } = configureStore(history) | |
await store.dispatch(fetchUser(req.cookies.sessionId)) | |
initialDispatch() | |
if (doesRedirect(store.getState().location, res)) return false | |
await thunk(store) | |
if (doesRedirect(store.getState().location, res)) return false | |
const status = location.type === NOT_FOUND ? 404 : 200 | |
res.status(status) | |
return store | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment