如何在reactjs中将数据从功能组件传递到类组件?

如何在reactjs中将数据从功能组件传递到类组件?,reactjs,react-redux,Reactjs,React Redux,我想将数据从App.js文件传递到一个子类组件。我尝试过使用道具,但根本不起作用 const org = 'Organization Dashboard' const remotes = 'FromAdmin'; const DashboardContainer = ()=>( <Sidebar org={org}> <div className="App"> <Route path='/dashboard' component={Dashbo

我想将数据从App.js文件传递到一个子类组件。我尝试过使用道具,但根本不起作用

const org = 'Organization Dashboard'
const remotes = 'FromAdmin';
const DashboardContainer = ()=>(
  <Sidebar org={org}>
  <div className="App">
    <Route path='/dashboard' component={Dashboard}/> 
    <Route path='/mytab' component={MyTab}/>
    <Route path='/team' component={MyTeam}/>
    <Route path='/settings' component={Settings}/>
    <Route path='/logout' component={Logout}/>
    <Route path='/team-settings/:param1' component={TeamSettings}/>
    **<Route remotes='remotes' path='/user-settings/:param1'   component={MyTab}/>**
  </div>
  </Sidebar>
)
const org='Organization Dashboard'
const remotes='FromAdmin';
常量仪表板容器=()=>(
****
)
我想在MyTab类组件中传递数据,当我在MyTab中使用this.props时,它显示为未定义


非常感谢您的帮助

我想您正在尝试将
remotes='remotes'
传递到
MyTab
。由
路由渲染的组件仅传递,但您可以使用匿名内部函数插入额外的道具。如果你需要道具,别忘了传递它们

}
/>

我假设您试图将
remotes='remotes'
传递到
MyTab
。由
路由渲染的组件仅传递,但您可以使用匿名内部函数插入额外的道具。如果你需要道具,别忘了传递它们

}
/>

您可以覆盖组件。默认情况下,组件接受基于类或基于函数的组件。但是您可以覆盖组件。您不仅可以传递数据,还可以传递函数。但你不应该这样做。使用redux来实现这种事情。如果它是静态数据,则可以通过此方式传递。但是如果它是动态数据,则使用redux

}
/>

您可以覆盖组件。默认情况下,组件接受基于类或基于函数的组件。但是您可以覆盖组件。您不仅可以传递数据,还可以传递函数。但你不应该这样做。使用redux来实现这种事情。如果它是静态数据,则可以通过此方式传递。但是如果它是动态数据,则使用redux

}
/>

太好了,别忘了将问题标记为已回答/已解决。太好了,别忘了将问题标记为已回答/已解决。
<Route
  path='/user-settings/:param1'
  component={routeProps => <MyTab {...routeProps} remotes='remotes' />}
/>