我正在學(xué)習(xí) React。我有一個(gè)帶有表單(“/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("/")它不起作用,它給出了以下錯(cuò)誤消息: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)有誰知道如何修理它?謝謝?。?
使用 React 提交表單后如何重定向用戶
慕運(yùn)維8079593
2021-12-02 19:17:18