0

Tengo problemas en enviar datos a una función que esta en otra pantalla:

El código es el siguiente:

Archivo App.js name es el parametro que deseo enviar

import React from 'react';
import Drawer from './scr/drawer1';

export default function App() {
 
  return (

    <Drawer name="MI_NOMBRE" appe="2"/

//name es el parametro que deseo enviar

  );
}

Archivo drawer1.js

import React, { Component } from 'react';
import { Text, View, AsyncStorage } from 'react-native';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';

function CompleScreen(route) {
  const { user } = route.params;
    return (
      <View>
        <Text>"Esto CompleScreem con name: {JSON.stringify(user)}</Text>  
      </View>
      )
}

const Stack = createStackNavigator();

export default function Drawer(props) {

    return (

//Hasta aquí llega props.name pero no lo puedo envíar a la funcion CompleScreen

      <NavigationContainer>
       <Stack.Navigator>
         <Stack.Screen name="Completorio" component={CompleScreen} params= { user: 'props.name' } /
       </Stack.Navigator>
     </NavigationContainer> 
   )
}

//intento enviar el parámetro pero no me funciona

agradezco cualquier ayuda, soy nuevo con React Native

1 respuesta 1

0

encontré el error. No es params, es initialParams:

initialParams={{ user: props.name }}

Fijate si funciona y avisame! Referencia: https://reactnavigation.org/docs/params/#updating-params Saludos.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.