私が反応し、ルータを/dashboard
パスの下でネストされたUIを取得しようとしているので、私が得た:反応ルータでネストされたルートを正しく使用する方法は?
<Route
path={'/dashboard'}
component={Components.Dashboard}
onEnter={utils.onlyAfterLogin}>
<Route
path={'/tiendas'}
component={Components.StoresIndex} />
</Route>
私は'/dashboard'
は、それ自身のUIのものを持つ親ルートであること、およびネストされたとしてレンダリングネストされたUIを含めたいですパス。したがって、'/dashboard/tiendas'
はダッシュボードのものをレンダリングする必要があります。また、Components.StoresIndex
コンポーネントもレンダリングする必要があります。
私は'/dashboard/tiendas'
にアクセスしようとすると、それは警告ログをスロー:
warning: [react-router] Location "/dashboard/tiendas" did not match any routes
ダッシュボードのものがが素敵なレンダリングされ、これは、ダッシュボードコンポーネントは(唯一のrenderメソッドを示す)のようになります。
render() {
return (
<div>
<AppBar
title="Distribuidores Movistar"
onLeftIconButtonTouchTap={() => {this.setState({leftNavOpen:true})}}
iconElementRight={
<IconMenu
iconButtonElement={
<IconButton><MoreVertIcon /></IconButton>
}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
anchorOrigin={{horizontal: 'right', vertical: 'top'}}
>
<MenuItem primaryText="Cerrar sessión" />
</IconMenu>
}
/>
<LeftNav open={this.state.leftNavOpen}>
<MenuItem>Ventas</MenuItem>
<MenuItem>Inventario</MenuItem>
<MenuItem>Usuarios</MenuItem>
<MenuItem>Tiendas</MenuItem>
<MenuItem>Configuraciones</MenuItem>
<Divider/>
<FloatingActionButton mini={true} style={{marginRight: 20}}>
<ContentAdd />
</FloatingActionButton>
</LeftNav>
<Link to={'/dashboard/tiendas'}>Akira</Link>
{this.props.children}
</div>
);
}
これはとても感謝しました。 – diegoaguilar