-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
what is a proper way to make redirect in onEnter or thunk callback? #50
Comments
How's this: import { redirect } from '@respond-framework/rudy';
const routes = {
FOO_BAR: {
path: '/foo/:bar?',
onEnter: ({ action, dispatch }) => {
if (!action.params.bar) {
dispatch(redirect({
type: 'FOO_BAR',
params: {
bar: 'first',
},
));
}
},
}
}; The It might be a good idea to to it in a callback that runs on the server though (e.g. in |
Thanks. Exactly what I was looking for. Should we keep issue open until it is documented or should I close it now? |
@hedgepigdaniel do we have |
You can see all the callbacks in the code here: rudy/packages/rudy/src/core/createRouter.js Lines 39 to 54 in 3c18480
documentation definitely needed. I think thunk is more for backwards compatibility with RFR. But they vary in terms of:
You are free to customise them by passing your own middlewares to createRouter. |
I want to have some parts of url to be optional with default values set in onEnter callback.
Eg., for route
/foo/:bar?
I want a link to/foo
properly redirected to/foo/first
with current entry replaced in history instead of pushing new one.The text was updated successfully, but these errors were encountered: