1
resposta

Esta dando erro ao criar a Rota

Meu codigo:

 import { BrowserRouter, Routes, Route } from "react-router-dom";
<BrowserRouter>
  <Route path="/favoritos" element={<p>Oi!</p>} />
  <Route path="/" element={<App />} />
</BrowserRouter>

O erro apresentado:

Uncaught runtime errors:

ERROR A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .

1 resposta

Boa tarde Silvestre,

Você precisa englobar suas rotas dentro do componente <Routes> do react-router-dom

<BrowserRouter>
    <Routes>
          <Route path="/favoritos" element={<p>Oi!</p>} />
          <Route path="/" element={<App />} />
      </Routes>
</BrowserRouter>