Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
How to put <Route children={({match})} => ... > in Jsx fragment. React router dom v6

return ( <> Some jsx..

            <Route
                path={modal.info ? `/fullInfo/${this.state.modal.id}`:`/preview/${this.state.modal.id}`}
                element={({match}) => {
                    return (
                        <ModalWindow
                            modalVisible={Boolean(match)}
                            onCloseWindow={this.onCloseWindow}
                            modalContent={modal}
                        />
                    )
                }}
            />
            
        </>
    )

If I do that I get an error like: Route tag must be wrapped by Routes tag. I did this feature in a old version of react-router-dom but when I try to do it in the new one there is err..

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In your App.js file, wrap the entire app with <BrowserRouter>

const AppWithRouter = () => <BrowserRouter><App /></BrowserRouter>
export default AppWithRouter

And then wrap all your routes in the new <Routes> tag (replaces switch):

<Routes>
  <Route path="..." element={...} />
</Routes>
about 4 years ago · Juan Pablo Isaza Denunciar

0

The Routes component effectively replaced the Switch component from v5, and it's required to wrap any Route components. Additionally, the Route components no longer take component, and render and children prop functions, the routed components must use the element prop that takes a ReactElement, a.k.a. JSX.

Wrap the Route component in a Routes component and since all routes are always exactly matched, just render the ModalWindow with the modalVisible prop set to true.

return (
  <>
    ...Some jsx...
    <Routes>
      <Route
        path={modal.info
          ? `/fullInfo/${this.state.modal.id}`
          :`/preview/${this.state.modal.id}`
        }
        element={(
          <ModalWindow
            modalVisible
            onCloseWindow={this.onCloseWindow}
            modalContent={modal}
          />
        )}
      />
    </Routes>    
  </>
)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda