Javascript 关于重定向到当前路由的反应路由器错误。不确定如何正确构造路由
我有一份回购协议来重现这一点,并看到错误: 我的路线的基本结构如下:Javascript 关于重定向到当前路由的反应路由器错误。不确定如何正确构造路由,javascript,reactjs,react-router,react-router-v4,Javascript,Reactjs,React Router,React Router V4,我有一份回购协议来重现这一点,并看到错误: 我的路线的基本结构如下: // app/app.js const render = Component => { ReactDOM.render( <AppContainer> <Provider store={ store }> <ConnectedRouter history={ history }>
// app/app.js
const render = Component => {
ReactDOM.render(
<AppContainer>
<Provider store={ store }>
<ConnectedRouter history={ history }>
<Route component={ Component } />
</ConnectedRouter>
</Provider>
</AppContainer>,
document.getElementById('react-root')
)
}
// app/containers/App/index.js
<div className='app'>
<Switch location={ location }>
<Route exact path='/' render={() => (
loggedIn ? (
<Redirect to='/organizations' push />
) : (
<Redirect to='/onboarding' push />
)
)}/>
<Route path='/organizations' component={ Organizations } />
<Route path='/onboarding' component={ Onboarding } />
<Route path='/settings' component={ Settings } />
</Switch>
</div>
// app/flows/onboarding/Onboarding/index.js
<div>
<Route exact path={`${match.url}`} component={ Start }/>
<Route path={`${match.url}/signup`} component={ SignUp }/>
<Route path={`${match.url}/name`} component={ Name }/>
<Route path={`${match.url}/structure`} component={ Structure }/>
<Route path={`${match.url}/pricing`} component={ Pricing }/>
<Route path={`${match.url}/continue`} component={ Continue }/>
</div>
// app/flows/onboarding/Start/index.js
<div className='start'>
Start Page
</div>
//app/app.js
常量呈现=组件=>{
ReactDOM.render(
在渲染函数中,更改
<Route component={ Component } />
到
另外,您不需要将位置
作为道具传递到App
中的开关
,该开关不起作用。哪个呈现函数?第一个App.js的?我这样做了,我得到了一个类型错误:无法读取未定义的错误的属性“pathname”。但是,删除了开关中的位置。是的,我指的是调用ReactDOM.render
的render
函数。只是为了澄清一下,听起来像是从开关中删除location
,但是为您修复了它,对吧?实际上它不起作用,它破坏了我的动画。现在不是淡出旧页面,而是淡入新页面。它复制了组件和f一进一退,看起来非常尴尬。动画听起来像是一个单独的问题。路由现在应该可以正常工作了
<Component />