为此,我正在检查用户是否在componentDidMount()中进行身份验证,如果没有,我将使用<Redirect to="/login"/> balise将用户重定向到/login。问题是,我有一个错误:You should not use <Redirect> outside a <Router>,尽管我在<BrowserRouter>中imp
在我的render中,我触发了一个函数来将用户重定向到不同的页面,但是我得到了一个错误的Cannot update during an existing state transition (such我注意到,如果我将redirectToPath函数(在render中)放在setTimeout中,它允许状态完成转换,错误也就消失了。如果我将history.push(path)和setState (在redirectToPath中)放在一