Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 当在特定路线上时,如何使用react router在布局上获取组件?_Reactjs_React Router - Fatal编程技术网

Reactjs 当在特定路线上时,如何使用react router在布局上获取组件?

Reactjs 当在特定路线上时,如何使用react router在布局上获取组件?,reactjs,react-router,Reactjs,React Router,我有一个index.js文件,其中包含所有路由 <Router history={hashHistory}> <Route path="/" component={Layout}> <IndexRedirect to={'dashboard'}/> <Route path="dashboard" component={Dashboard} /> <Route path="donors" >

我有一个index.js文件,其中包含所有路由

<Router history={hashHistory}>
    <Route path="/" component={Layout}>
      <IndexRedirect to={'dashboard'}/>
      <Route path="dashboard" component={Dashboard} />
      <Route path="donors" >
        <IndexRoute component={Donors} />
        <Route path=":id" component={SingleDonor} />
      </Route>
      <Route path="repository" component={Repository} />
      <Route path="groups"  background={'premium'} premiumText={'groups is a premium feature'}>
        <IndexRoute component={Groups} />
        <Route path=":name" component={SingleGroup} />
      </Route>
      <Route path="campaigns" component={Campaigns} background={'premium'} premiumText={'campaings is a premium feature'}/>
      <Route path="followups" component={Followups} background={'premium'} premiumText={'followups is a premium feature'} />
      <Route path="settings" component={Settings}  background={'premium'} premiumText={'settings is a premium feature'}/>
      <Route path="subscriptions" component={Subscription} background={'premium'} premiumText={'creating a great product for the best price'} />
    </Route>
    <Route path="*" component={NotFound} />
  </Router>
解决这个问题的办法是什么。此外,如果这是一个重复的人可以请重定向到可能的解决方案,因为我无法找到它我。提前谢谢

<div>
      <Sidebar userData={this.state.userData} ngo={this.state.ngo}
              lockPortal={this.lockPortal}
      />
      <TopMenu userData={this.state.userData}
              logoutUser={this.logoutUser}
      />
      {React.cloneElement(this.props.children, { ngo: this.state.ngo })}
</div>