redux-history-transitions
redux-history-transitions copied to clipboard
How to navigate backwards?
How to use standard navigation actions of react-router, i.e. goBack(), replace() etc?
How to use replace is described here. Besides push and replace not other methods are currently supported.
I badly need goBack with great library!
On Monday, August 22, 2016, Johannes Lumpe [email protected] wrote:
How to use replace is described here https://github.com/johanneslumpe/redux-history-transitions#can-i-perform-replace-transitions-instead-of-push. Besides push and replace not other methods are currently supported.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johanneslumpe/redux-history-transitions/issues/10#issuecomment-241388451, or mute the thread https://github.com/notifications/unsubscribe-auth/AD9MIxgGA9v0HNs00Gsj-6onACkvlHfUks5qiYssgaJpZM4Jpld0 .
Best Regards, Ivan Borisenko
I wonder if this'll work. Modify executeTransition like below. Adds an additional check for a key named method in your transition definition. I feel it could be safe cuz I believe neither history API nor react-router consume a method key in any of their operations.
export const executeTransition = history => transitionData => {
if (transitionData) {
// const method = transitionData.replace ? 'replace' : 'push';
const method = transitionData.method || (transitionData.replace ? 'replace' : 'push');
history[method](transitionData);
}
};
Example action:
export default {
goPrevious() {
return {
type: PAGE_PREV,
payload: {
page: 23
},
meta: {
transition: (prevState, nextState, action) => ({ method: 'goBack' }),
},
};
},
}
A goBack and goForward feature would be most welcome.