Skip to content

Instantly share code, notes, and snippets.

@faceyspacey
Created August 8, 2017 06:39
Show Gist options
  • Save faceyspacey/fc0e3fdacbd7c483fc03e6b5ccc07811 to your computer and use it in GitHub Desktop.
Save faceyspacey/fc0e3fdacbd7c483fc03e6b5ccc07811 to your computer and use it in GitHub Desktop.
redux-first router server/configureStore.js (simple - no promise all, no redirect)
import createHistory from 'history/createMemoryHistory'
import { NOT_FOUND } from 'redux-first-router'
import configureStore from '../src/configureStore'
export default async (req, res) => {
const history = createHistory({ initialEntries: [req.path] })
const { store, thunk } = configureStore(history)
await thunk(store) // THE PAYOFF!
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