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

179
Visualizações
react-router-dom not rendering my component

I am trying to make a simple registration program with react JS but got stuck when it is not able to render my App and Register component .

 import React from "react";
 import ReactDOM from "react-dom";
 import { BrowserRouter, Routes, Route } from "react-router-dom";
 import App from "./App";
 import Register from "./screens/Register";

 ReactDOM.render(
 <BrowserRouter>
  <Routes>
   <Route path="/" exact render={(props) => <App {...props} />} />
   <Route
    path="/register"
    exact
    render={(props) => <Register {...props} />}
    />
  </Routes>
 </BrowserRouter>,
 document.getElementById("root")
 );
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As much as I know, there isn't any prop like render in the routecomponent of react-router@v6. There is hooks that are usable in your pages to get data related to the routing. You will find them in the official documentation. (Consider reading the links about migration from the v5 or from react-router).

You can of course still pass regular props in your component. See an example on Stackblitz here and here is the code :

import React, { Component } from 'react';
import { render } from 'react-dom';
import { BrowserRouter, Routes, Link, Route } from 'react-router-dom';
import './style.css';

const Page1 = (props) => <Link to="page2"> {props.test} - Go to Page 2</Link>;
const Page2 = () => <Link to="/">Go to Page 1</Link>;

const App = () => {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" exact element={<Page1 test="Test" />} />
        <Route path="/page2" exact element={<Page2 />} />
      </Routes>
    </BrowserRouter>
  );
};

render(<App />, document.getElementById('root'));
about 4 years ago · Juan Pablo Isaza Relatório
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