路由未在嵌套路由组件内加载组件

时间:2019-04-19 17:09:17

标签: reactjs react-router-dom

我正在adminDashboard中将app.js的{​​{1}}组件加载到Route中。现在基于URL在adminDashboard中,我想呈现一些组件。但是,它没有加载任何组件。此外,Chrome控制台的“网络”标签上没有任何活动。

如果我在不使用Route的情况下渲染它们,则它们可以正常渲染。

app.js

class App extends Component {

  render() {
    let { error, success } = this.props;
    const Admin = Authorization(['admin'])
    return (
      <div className='app'>
        <AdminNavbar logout={this.props.logout}/>
        <Switch>
          <Route exact path='/admin/signin' render={(props) => {
              return <AuthForm />
            }}
          />
          <Route exact path='/admin' component={Admin(AdminDashboard)} />
        </Switch>
        <Footer />
      </div>
    );
  }
}

MyComponent组件

const MyDashboard = (props)=> ` this is dashboard`

管理控制台

class AdminDashboard extends Component{
    render() {
        return (
            <div>
                <div className='row'>
                    <div className='col-md-2'>
                        <NavBar  />
                    </div>
                    <div className='col-md-10'>
                        < Commisions /> //working properly if i load it without route
                        <Switch>

                            <Route exact path='/admin/dashboard' component={MyDashboard} /> // not work
                            //some other route
                        </Switch>
                    </div>
                </div>
            </div>
        )
    }
}

0 个答案:

没有答案
相关问题