Created
March 21, 2017 18:20
-
-
Save cellog/273563db116cdea9fa4efd502c1b370e to your computer and use it in GitHub Desktop.
More in-depth example
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
import Routes from 'react-redux-saga-router/Routes' | |
import Route from 'react-redux-saga-router/Route' | |
import * as actions from './actions' | |
const stateFromParams = (params) => | |
(params.id === 'new') ? { id: true } : { id: params.id ? params.id : false } | |
function paramsFromState(state) { | |
if (state.records.selectedRecord) { | |
return { | |
id: state.records.selectedRecord === true ? 'new' : state.records.selectedRecord | |
} | |
} | |
return { | |
id: undefined | |
} | |
} | |
const updateState = { | |
id: id => actions.selectRecord(id) | |
} | |
export default () => ( | |
<Routes> | |
<Route name="records" path="/records(/:id)" | |
stateFromParams={stateFromParams} | |
paramsFromState={paramsFromState} | |
updateState={updateState} | |
/> | |
</Routes> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment