• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

392
Views
React-Router V6: cómo agregar transiciones al usar el gancho useRoutes()

Estoy usando react-router v6 con el gancho useRoutes() ( docs ).

Y estoy tratando de agregar transiciones de ruta con react-transition-group .

Probé un montón de cosas diferentes, pero las animaciones simplemente no están limpias y no funcionan para las rutas secundarias: todo el diseño se anima en lugar del elemento secundario.

 export const App = () => { const routes: RouteObject[] = [ { path: "/", element: <Layout />, children: [ { index: true, element: <Home /> }, { path: "/courses", element: <Courses />, children: [ { index: true, element: <CoursesIndex /> }, { path: "/courses/:id", element: <Course /> }, ], }, { path: "*", element: <NoMatch /> }, ], }, ]; const element = useRoutes(routes); const location = useLocation() return ( <TransitionGroup> <CSSTransition key={location.key} classNames="slide" timeout={1000} > {element} </CSSTransition> </TransitionGroup> ); } export const Layout = () => { return <Outlet />; }
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error