我正在学习 React。我有一个带有表单(“/login”)的登录页面,在成功提交后,我想将用户重定向到域的根路径(“/”)。我正在使用似乎工作正常的 Redux。我的代码是:
const handleSubmit = (e) => {
e.preventDefault()
setSubmitBtn(true)
setTimeout(async (e) => {
const { data } = await axios.post( axiosURL + '/login', inputs)
dispatch({ type: 'LOGIN' })
history.push("/")
setReturnMessage(data.message)
setSubmitBtn(false)
}, 1000)
}
问题是history.push("/")它不起作用,它给出了以下错误消息:
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
in Login (created by Context.Consumer)
in Route (at routes.js:36)
有谁知道如何修理它?谢谢!!
DIEA
相关分类