Skip to content

Instantly share code, notes, and snippets.

@jrwebdev
Last active May 19, 2016 08:32
Show Gist options
  • Save jrwebdev/007c27fc238b6616a65a78f1d559a4c0 to your computer and use it in GitHub Desktop.
Save jrwebdev/007c27fc238b6616a65a78f1d559a4c0 to your computer and use it in GitHub Desktop.
redux-ui-router React wrapper
import {stateGo} from 'redux-ui-router';
const stateMap = {
'/': 'index',
'/page1': 'page1',
'/page2': 'page2'
}
const push = url => {
// getPath() and getParams() are example functions
const state = stateMap[getPath(url)];
const params = getParams(url);
return stateGo(state, params);
}
const replace = url => {
const state = stateMap[getPath(url)];
const params = getParams(url);
return stateGo(state, params, {location: 'replace'});
}
export {push, replace}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment