stack-navigator

`componentDidMount()` function is not called after navigation

北城以北 提交于 2019-11-27 16:04:56
问题 I am using stackNavigator for navigating between screens. I am calling two API's in componentDidMount() function in my second activity. When i load it first time, it gets loaded successfully. Then i press back button to go back to first activity. Then, if i am again going to second activity, the APIs are not called and I get render error. I am not able to find any solution for this. Any suggestions would be appreciated. 回答1: If anyone coming here in 2019, try this: import {NavigationEvents}

StackNavigator through Component gives undefined error

筅森魡賤 提交于 2019-11-26 16:49:32
I was trying to use StackNavigator for navigation and it works when I use it to go from one screen to the other as explained here . But when I try to have a subcomponent to navigate through itself, the navigation doesn't seem to work and I couldn't find any solution to it. As given in the code below, I'm trying to use the Test Component in which there is a button that can be clicked to move from HomeScreen to ChatScreen. I'm pretty sure the solution is something basic, but I really can't find it anywhere. Here's my code: import React from 'react'; import { AppRegistry, Text, View, Button }