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

217
Visualizações
No routes matching location "/dash/1"

I have the following problem. my route is not registered and i dont know why.

Links

dashboard.jsx

this code generates all the links.

    <div className="flex w-3/4 m-auto flex-col mt-10 xl:w-1/2">
            {questions.map(({ id, question }) => {
                return (
                    <Link to={`/dash/${id}`}>
                        <QuestionHeader question={question} />
                    </Link>
                );
            })}
        </div>

/dash/1,/dash/2,.... are generated by the map function above.

i have two files that represent the routes.

NavRoutes

const NavRoutes = () => {
    return (
        <Routes>
            <Route path="/:id" element={<Question />} />
            <Route path="" element={<Dashboard />} />
        </Routes>
    );
};
export default NavRoutes;

here is the Main component


const Main = () => {
    return (
        <div>
            <NavBar />
            <NavRoutes />
            <Footer />
        </div>
    );
};

export default Main;

and the main routes for authentication and accessing the main page

const App = () => {
    let { user } = useAuthContext();
    return (
        <div className="w-full bg-slate-700 block fixed h-full">
            <Header />
            <Router>
                <Routes>
                    <Route
                        path="/dash"
                        element={!user ? <Navigate to="/auth" /> : <Main />}
                    >
                    </Route>
                    <Route path="" element={<Login />} />
                </Routes>
            </Router>
        </div>
    );
};

when i try to access /dash/1, i get the following error

router.ts:11 No routes matched location "/dash/1" 
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Did you try the following in your NavRoutes (prepending '/dash' to '/:id'):

<Route path="/dash/:id" element={<Question />} />
about 4 years ago · Juan Pablo Isaza Relatório

0

i solved this by doing the following

const App = () => {
    let { user } = useAuthContext();
    return (
        <div className="w-full bg-slate-700 block fixed h-full">
            <Header />
            <Router>
                <Routes>
                    <Route
                        path="/dash/*"
                        element={!user ? <Navigate to="/auth" /> : <Main />}
                    >
                    </Route>
                    <Route path="/auth" element={<Login />} />
                </Routes>
            </Router>
        </div>
    );
};

you need to include a * when nesting deeper

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