Skip to content

Instantly share code, notes, and snippets.

@cellog
Created March 21, 2017 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cellog/2d9611335e96f50f91e99af0955d3d12 to your computer and use it in GitHub Desktop.
Save cellog/2d9611335e96f50f91e99af0955d3d12 to your computer and use it in GitHub Desktop.
mocking history for server-side use with react-redux-saga-router
const connect = require('react-redux').connect
const router = require('react-redux-saga-router').default
const sagaMiddleware = require('redux-saga').default
app.use('*', (req, res) => {
const serverHistory = {
location: require('url').parse(request.url)
action: 'PUSH',
listen: () => null
}
// set up store, redux-saga middleware here
// set up the router, parse the initial route
router(sagaMiddleware, connect, [], serverHistory)
// here, the store correctly contains the URL state
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment