Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
React Native route.params is undefined

I've been trying to pass data from my home.js screen to my merchant.js screen by using navigation.navigate('Merchant', store ) but when I try to actually use route.params I get undefined.

Here's my home.js

export default function Home( { navigation }) {
...
{storeData.map(store => {
    return (
     <View>
      <TouchableOpacity>
        <Text style={styles.categoryName}
          onPress={() => {navigation.navigate('Merchant', store)}}>
         {store.name}
        </Text>
      </TouchableOpacity>

Merchant.js

function Merchant({ navigation, route }) {
    console.log(route);
...
}

Output:

{"key": "Merchant-86K9u5ytF32VGMRcO9s2g", "name": "Merchant", "params": undefined}

Again I have no idea what is going on. I've tried navigation.push(), I've tried using navigate('Merchant', {name: store.name}) but I still get undefined.

If you would like to paste more code with my stack navigation I can.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Have you try this?

navigation.navigate('Merchant', store)

Access the value by:

navigation.getParam('onePropertyOfStoreHere');
about 4 years ago · Juan Pablo Isaza Relatório

0

Alright, so I figured why it was undefined. It was because I had another stack that started with Merchant.js on the top.

<Stack.Navigator initialRouteName="Merchant" headerShown='false'>
    <Stack.Screen name="Merchant" component={Merchant} />
    <Stack.Screen name="ProductInfo" component={ProductInfo}/>
</Stack.Navigator>

This must of confused the app as I was moving from Home to Merchant screen but it went into another stack.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda