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

439
Views
Texto mecanografiado: obtener `reemplazar` de useNavigation() en react-navigation con react-native v6

Esta pregunta se parece a esto : ¿cómo usar navigation.replace en TypeScript? que es para reaccionar-navegación 5.

También leí los documentos https://reactnavigation.org/docs/typescript/#annotating-usenavigation

Intenté un par de formas diferentes, pero me confundí más 🙃.

 import { BottomTabScreenProps } from '@react-navigation/bottom-tabs' import { CompositeScreenProps, NavigatorScreenParams } from '@react-navigation/native' import { NativeStackScreenProps } from '@react-navigation/native-stack' import { AxiosError } from 'axios' declare global { namespace ReactNavigation { interface RootParamList extends RootStackParamList {} } } export type RootStackParamList = { SignIn: undefined ResetPassword: { email?: string } | undefined Root: NavigatorScreenParams<RootTabParamList> | undefined Modal: undefined Error: { error?: AxiosError | null } | undefined DevToolsSignIn: undefined } export type RootTabParamList = { Overview: undefined Returns: undefined Portfolio: undefined More: undefined } export type RouteName = keyof RootStackParamList | keyof RootTabParamList export const routeTypeGuard = (route: RouteName) => route as keyof RootStackParamList export type RootStackScreenProps<Screen extends keyof RootStackParamList> = NativeStackScreenProps< RootStackParamList, Screen > export type RootTabScreenProps<Screen extends keyof RootTabParamList> = CompositeScreenProps< BottomTabScreenProps<RootTabParamList, Screen>, NativeStackScreenProps<RootStackParamList> >

luego, en un componente, deseo decirle a mecanografiado que debería poder destruir replace desde useNavigation()

 export default ({ route }: RootStackScreenProps<'ResetPassword'>) => { const { replace } = useNavigation<?🙃?>() const email = route.params?.email if (!email) replace('Error') return ( <ScreenContainer> <Text style={{ color: 'hotpink' }}>{email}</Text> </ScreenContainer> ) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

esto parece hacer el truco

 const { navigate, replace } = useNavigation<NativeStackNavigationProp<RootStackParamList>>()

que me permite hacer cosas como:

 replace('Root')

sin problemas de TS.

Mi malentendido fue que el reemplazo no puede reemplazar a ninguna pantalla que desee; solo puede reemplazar a cualquier pantalla dentro de la navegación en la que se encuentra.

about 4 years ago · Juan Pablo Isaza 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!