I am working on a react project and I am using react-firebase-hooks to create or sign in users. Whenever I create a new user, this warning pops up, I am changing the login to a button to logout and redirecting the user to the home page after registering,
if (user) {
navigate('/home');
}
The error,
react-dom.development.js:86 Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`Register`). To locate the bad setState() call inside `Register`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
at Register (http://localhost:3000/main.4ec98b661e1297c4a8cc.hot-update.js:259:64)
at Routes (http://localhost:3000/static/js/bundle.js:77696:5)
at div
at App
at Router (http://localhost:3000/static/js/bundle.js:77629:15)
at BrowserRouter (http://localhost:3000/static/js/bundle.js:76438:5)