I am using React-router recently and found it was not that intuitive. Here is my case. I defined a stateless React component "MainLayout" which has two parameters to include "headerBar" component and "children" component.
mainlayout.js:
const MainLayout = ({children,headerBar})=>{
return (
<div className="app">
{headerBar}
<main>
{children}
</main>
</div>
);
}
export default MainLayout;
My routes are like this:
routes.js:
export default (
<Router history={browserHistory}>
<Route component={MainLayout}> -----> how to specify "headerBar"
<Route path="/" component={Home} />
<Route path="widgets">
<Route component={SearchLayout}>
<IndexRoute component={WidgetList} />
</Route>
</Route>
</Route>
</Router>
);
In such a case, how to specify "headerBar" in Route of "MainLayout"?
Thanks
Derek