我有一个这样的组件
class myApp extends React.Component {
return (
<div>
<NavigationBar />
{/* dynamic_content */}
</div> )
}
使用此路线
<Router>
<Route exact path="/" component={myApp}/>
</Router>
而且负载很好。
我想实现的是,例如,当url更改时
/profile
/notifications
这个
dynamic_content
更新,而不实际转换到另一个组件。
在伪代码中,我想要的是
class myApp extends React.Component {
return (
<div>
<NavigationBar />
{route === '/profile' -> <Profile/>
route === '/notification' -> <Notification/>}
</div> )
这可能吗?
我该怎么做?