-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
child routes seem not to work #35
Comments
@Dmitry-N-Medvedev |
I'm using react-starter-kit... Do I require to make changes to it to have child routes operational? |
Child routes should work in react-starter-kit out of the box. I will test your use case in RSK.. |
Any word on this? I've come across the same issue with RSK. Thanks! |
I got the same issue, children router not working |
I found solution:
|
@chilic not working for me: export default {
path: '/contact',
async action() {
const Contact = await new Promise((resolve) => {
require.ensure([], (require) => resolve(require('./Contact').default));
});
return <Contact />;
},
children: [
{
path: '/', // Same as /parent
action: () => <Contact />,
},
{
path: '/contact/name', // Same as /parent
action: async () => {
console.log('in name router')
return <h1>good</h1>
},
},
],
}; |
@dreambo8563
|
@chilic you save my world this works export default {
path: '/contact',
// async action() {
// const Contact = await new Promise((resolve) => {
// require.ensure([], (require) => resolve(require('./Contact').default));
// });
// return <Contact />;
// },
async action({ next }) {
const component = await next();
return component;
},
children: [
{
path: '/', // Same as /parent
action: () => <Contact />,
},
{
path: '/name',
action: async () => {
console.log('in name router')
return (
<div>
<h1>good</h1>
<Contact />
</div>
)
},
},
],
}; |
This should be fixed, please reopen if necessary. |
Solution given by @chilic works but this needs to be solved. I guess for this to work, child route must be resolved before parent route, when both child and parent routes are available. |
The right way here is: const routes = {
path: '/users', // base url
children: [
{
path: '/', // main page
action() { return 'User List' }
},
{
path: '/:id', // child page
action(context) { return `User #${context.params.id}` }
},
]
}; Playground: https://jsfiddle.net/frenzzy/o50uu79q/ |
@frenzzy Above solution given works as expected. It will be great if we could get a warning that children route and parent action are available together. Easy to do this mistake for user of the router. |
The following code in will never hit the /:cid subpath:
The text was updated successfully, but these errors were encountered: