Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

510
Visualizações
Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`Social`)

I'm getting this warning from ReactJS whenever I log in with social login. If I refresh the page, the warning goes away. I couldn't understand what it meant and didn't find any solution. How to fix this?

Here is the full warning

Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`Social`). To locate the bad setState() call inside `Social`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
at Social (http://localhost:3000/static/js/bundle.js:3074:130)
at form
at div
at Login (http://localhost:3000/static/js/bundle.js:1613:78)
at Routes (http://localhost:3000/static/js/bundle.js:58827:5)
at div
at App
at Router (http://localhost:3000/static/js/bundle.js:58760:15)
at BrowserRouter (http://localhost:3000/static/js/bundle.js:57569:5)

Social.js

const Social = () => {
const [signInWithGoogle, user, loading, error] = useSignInWithGoogle(auth);
const navigate = useNavigate();
const location = useLocation();

const from = location?.state?.from?.pathname || '/';


if (user) {
    navigate(from, { replace: true });
}

return (
    <div>
        <div className='flex items-center'>
            <hr className='border-black w-5/12' />
            <p className='w-2/12 text-center'>Or</p>
            <hr className='border-black w-5/12' />
        </div>
        <div className='mt-3'>
            <p onClick={() => signInWithGoogle()} className='flex cursor-pointer justify-center items-center mx-auto text-white bg-slate-800 hover:bg-slate-900 p-1 rounded-md'><img className='w-4 h-4 mr-1' src={googleLogo} alt="" />Continue with Google</p>
        </div>
    </div>
);

};

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda