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

297
Views
No se puede actualizar un componente (`ForwardRef(BaseNavigationContainer)`) mientras se renderiza un componente diferente (`Home_Profile`)

Recibo este error al intentar navegar entre pantallas con el navegador de pila nativa de reacción. Creo que esto estaba funcionando en mi proyecto anterior que tenía react 17.0.1 y react native 0.64.2, este proyecto es react 17.0.2 y react native 0.66.4, se agradecería la ayuda.

Iniciar sesión

 Warning: Cannot update a component (`ForwardRef(BaseNavigationContainer)`) while rendering a different component (`Home_Profile`). To locate the bad setState() call inside `Home_Profile`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render

aparece un error cuando trato de llamar a la navegación en un accesorio onPress en un componente de elemento de representación Flatlist.

 renderItem={({ item }) => ( <View style={{ backgroundColor: "#f6f6f6" }}> <PostCard item={item} onPress={() => navigation.navigate("Home_Profile")} /> </View> )}
 const PostCard = ({ item, onPress }) => { React.useEffect(() => { async function fetchUserData() { const data = await getUserData(item.userid); setProfileimg(data.userimg); setName(data.name); setLocation(data.location); } fetchUserData(); }, []); return ( <TouchableOpacity onPress={onPress}> <Text style={{ color: "#231454", fontWeight: "bold", fontSize: 15, marginBottom: 3, }} > {name} </Text> </TouchableOpacity> ) }; export default PostCard;

Inicio_Perfil

 import React from "react"; import { View, Text, Button } from "react-native"; const Home_Profile = ({ navigation }) => { return ( <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> <Text>Home_Profile.js</Text> <Button title="back" onPress={navigation.navigate("Home")} /> </View> ); }; export default Home_Profile;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Encontré la causa del problema, cuando renderizas la segunda pantalla, está ejecutando el método onPress del botón que vuelve a casa, y esa navegación hace que se ejecute el método de renderizado en esa pantalla de inicio, lo que significa que estás intentando ejecutar dos renderizados al mismo tiempo, para arreglar eso, simplemente agregue una función de flecha a la función de navegación de inicio como se muestra a continuación:

 onPress={()=>{navigation.navigate("Home")}}
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!