在react native中从导航中接收参数

问题描述 投票:0回答:1

我想通过导航发送参数。但是Im Im参数总是不确定的。我不知道要尝试什么,因为我真的不知道代码有什么问题。

这里是我发送参数的地方。

 return (
    <View>
      {info.map((l, i) => (
        <ListItem
          key={i}
          title={l.NombreCliente}
          subtitle={
            <TouchableOpacity onPress={() => navigation.navigate("Abonos", { id: l.idClientes})} >
              <View
                style={{
                  flexDirection: "row",
                  paddingLeft: 10,
                  paddingTop: 5
                }}
              >
                <Text> Telefono: {l.Telefono} </Text>
                <Text> Cumpleaños: {l.FechaDeNacimiento} </Text>
              </View>
              <View
                style={{
                  flexDirection: "row",
                  paddingLeft: 10,
                  paddingTop: 5
                }}
              >
                <Text> Total Vendido: {l.total} </Text>
                <Text> Adeudo: {l.saldo_pendiente} </Text>
              </View>
            </TouchableOpacity>
          }
          bottomDivider
        />
      ))}
    </View>
  );

这里,我接收并显示参数。

const id = navigation.getParam("id");
console.log(id);

return(
    <View>
        <Text>
            El id del cliente es: {id}
        </Text>
    </View>
);
javascript react-native react-navigation
1个回答
0
投票

我认为您必须从道具访问导航,并且应该是这样的:

const id = this.props.navigation.getParam("id");
© www.soinside.com 2019 - 2024. All rights reserved.