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

106
Visualizações
Refactor custom route component after updating react-router-dom

I am working on a project, using this boilerplate https://github.com/ankushjain2001/fastapi-react-mongodb and updated the dependencies for the frontend to new major versions.

I already fixed some errors, but can't get custom routes refactored properly…

This is how it is used in the App.js <ProtectedRoute path="/admin" exact strict component={Home} />

And this is the Component itself

export const ProtectedRoute = ({component: Component, ...rest}) => {
  return (
    <Route 
      {...rest}
      render={props => {
        // Goto the concerned route when authenticated
        if (auth.isAuthenticated()){
          return <Component {...props}/>
        }
        // Goto the default login page when not authenticated
        else {
          return (
            <div>
              <Landing {...props}/>
            </div>
          )
        }
      }}
    />
  );
};

The error I am getting is:

Uncaught Error: [ProtectedRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

How can I fix this? Thanks in advance :)

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