Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

360
Views
No puedo usar el movimiento del enmarcador cuando uso <navigate/> react router dom v6 para autenticar mi página de inicio de sesión

¡¡necesito ayuda por favor!!

la animación en la página de inicio de sesión se carga normal, pero cuando uso AuthRoute para verificar la autenticación, por ejemplo, un enlace ... no puedo ver la animación cuando redirecciono :(((

este es mi codigo

authRoute.tsx

 import { useAppSelector } from "app/hooks"; import { AnimatePresence } from "framer-motion"; import React from "react"; import { Navigate, Outlet,useLocation } from "react-router-dom"; interface Props {} const AuthRoute = (props: Props) => { const location = useLocation(); const userType = useAppSelector( (state) => state.LoginReducer.currentUser?.userType ); if (userType === "user") { return <Navigate to="/signUp" state={{from:location}} replace /> } else if (userType === "admin") { return <Navigate to="/admin" state={{from:location}} replace />; } else return <Outlet />; }; export default AuthRoute;

aplicación.tsx

 import { ThemeProvider } from "@mui/material/styles"; import { NotFound } from "component/common"; import { AnimatePresence } from "framer-motion"; import LoginPage from "pages/Login/Login"; import SignUpPage from "pages/SignUp/SignUp"; import React from "react"; import { useLocation } from "react-router"; import { Route, Routes } from "react-router-dom"; import AuthRoute from "Routes/AuthRoute"; import { lightTheme } from "theme"; import "./App.css"; function App() { const location = useLocation(); return ( <ThemeProvider theme={lightTheme}> <AnimatePresence exitBeforeEnter> <Routes location={location} key={location.pathname}> {/* check user at localstorage and redirect to login form */} {/* check user login and redirect to home page */} <Route element={<AuthRoute />}> <Route path="/login" element={<LoginPage />} /> </Route> <Route path="/signUp" element={<SignUpPage />} /> <Route path="*" element={<NotFound />} /> </Routes> </AnimatePresence> </ThemeProvider> ); } export default App;

Estoy realmente confundido ya que lo intenté de muchas maneras pero no funciona.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Según tengo entendido, no estoy 100% seguro acerca de AnimatePresence, pero se activará solo una vez cuando se configure toda la aplicación, así que intente eliminar AnimatePresence como padre para todas las rutas y coloque el componente necesario de esta manera:

 <Route path="/login" element={ <AnimatePresence exitBeforeEnter> <LoginPage /> </AnimatePresence> } />
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!