は、私はあなたがこのようなレイアウト持つことができますね。あなたが持っているでしょう
<App>
<Navbar /> { /* Here you show the username also, this view will depend on props */ }
<Layout /> { /* Here you may have the content and the sidenav */ }
</App>
アプリケーションがトップ部品、render()を、例えば小道具を渡し本体容器です
// You should treat this as a Page component, the one that grabs
// data and passes it as props to another components
export default class AppPage extends React.Component {
render() {
return (<AppLayout { ...this.props } />);
}
}
export default class AppLayout extends React.Component {
render() {
return (
<Navbar someProp={ this.props.someProp } />
{ this.props.children }
);
}
}
ルータは、たとえば次のようになります。
<Router history={ browserHistory }>
<Route path="/" component={ App }>
<IndexRoute component={ Landing } />
<Route path="/index" component={ Layout } />
</Route>
</Router>
IndexRouteは '/'で、どのコンポーネントを私たちにするべきか例えば、あなたが/ layout {this.props。 children}は、<Layout />
コンポーネントとしてレンダリングされます。
私はあなたがこの記事を読むことをお勧め:https://facebook.github.io/react/docs/thinking-in-react.html は、より良い作品をどのように反応するかを理解するために...それはそれはナビゲーションバーの構成要素である必要があり
1.を助け願っています。 2.反応ルータは良い選択ですが、あなたがチェックアウトできる他の選択肢があります。 3.私はそれほど流動的ではないので、おそらく彼らのGitHub文書を読むべきです。 4. Reactは特定の種類の処理を行うコンポーネントに対して「コールバック」を持っているので、componentDidMountのときに$ .getを作ることができます。 5. Reduxは状態がどのように変化するかを記述する減速器ですが、より高度ですが、開始する場合は複雑に見えるかもしれません。 – MiGu3X
フィルタ値をナビゲーションに渡す必要がある場合はどうなりますか?たとえば、表示されている現在のデータをフィルタリングする「年」フィルタを使用できますか?このためにContextを使用しますか? – Nsevens