React-router4 split routing cannot render components?

I have a Layout component that looks like this:

render(){
    return(
        <a />
        <b />
        {this.props.children}
    )
}

then in App.js , router.js is a branch route:

import UserRouter from "user/router.js"
<Layout>
    <Switch>
        <Route exact path="/" component={Home} />
        <Route path="/user" component={UserRouter} />   
    </Switch>
</Layout>

my user directory looks like this:

user/
    index/
        index.js
    user-admin/
        index.js
    router.js

this is the case now. If the path is / user , render the UserRouter component, but because UserRouter is a sub-route, go to user/router.js to match the path:

class UserRouter extends Component{
    render(){
        return(
            <Switch>
                <Route path="/user/index" component={UserList} />
                <Redirect exact from="/user" to="/user/index" />
            </Switch>
        )
    }
}

in this path, if the path is / user , jump directly to / user/index , and then render UserList component.

after trying, I found that when accessing the / user path, I can jump directly to / user/index , but UserList is not loaded? Why is that?

Mar.24,2021

try whether / user/user/index can render the userlist component


has it been solved?


have you solved it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30f4b-2bd3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30f4b-2bd3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?