ignite-andross icon indicating copy to clipboard operation
ignite-andross copied to clipboard

not able to receive addListener willFocus

Open king804 opened this issue 6 years ago • 9 comments

componentDidMount(){
        this.props.navigation.addListener('willFocus', () =>{
            //don't work
        });
        this.props.navigation.addListener('didFocus', () =>{
            //don't work
        });
}

with react-navigation 3.0~3.9 also don't work

king804 avatar May 13 '19 05:05 king804

+1

lalithnarayan avatar May 13 '19 07:05 lalithnarayan

Could you please add the output of ignite doctor (run in the root of your app folder) so that we can tell what boilerplate and versions are you using?

ruddell avatar May 13 '19 16:05 ruddell

System platform darwin
arch x64
cpu 4 cores Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
directory /Users/lalithnarayankashyap/Documents/testApp

JavaScript node 10.15.3 /usr/local/bin/node
npm 6.9.0 /usr/local/bin/npm
yarn 1.7.0 /usr/local/bin/yarn

React Native react-native-cli 2.0.1
app rn version 0.57.7

Ignite ignite 2.2.3 /usr/local/bin/ignite
boilerplate ignite-andross

Android java 1.8.0_121 /usr/bin/java
android home - undefined

iOS xcode 10.2.1

My Navigation looks like

export default createAppContainer(createSwitchNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    App: MyDrawerNavigator,
    Auth: AuthStack,
  },
  {
    initialRouteName: 'AuthLoading',
  }
));
const MyDrawerNavigator = createDrawerNavigator({
  Home: {
    screen: home,
  },
},
  {
    contentComponent: DrawerComponent
  });

const AuthStack = createStackNavigator(
  {
    Login: LoginScreen,
  },
  {
    headerMode: 'none',
    initialRouteName: 'Login'
  }
);

this is my render

  render() {
    return (
      <Container>
        <NavigationEvents
          onWillFocus={payload => console.log('will focus', payload)}
          onDidFocus={payload => console.log('did focus', payload)}
          onWillBlur={payload => console.log('will blur', payload)}
          onDidBlur={payload => console.log('did blur', payload)}
        />
      </Container>

    )
  }

lalithnarayan avatar May 14 '19 01:05 lalithnarayan

here my ignite doctor

System platform darwin

arch x64
cpu 4 cores Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz

JavaScript node 10.15.3 /usr/local/bin/node npm 6.4.1 /usr/local/bin/npm
yarn 1.15.2 /usr/local/bin/yarn

React Native react-native-cli 2.0.1
app rn version 0.59.3

Ignite ignite 3.0.0-beta.3 /usr/local/bin/ignite boilerplate ignite-andross

Android java 1.8.0_211 /usr/bin/java
android home - /Users/sys_admin/Library/Android/sdk

iOS xcode 10.2

My Navigation looks like

const PrimaryNav = createStackNavigator({
  MainScreen: { screen: MainScreen },
});

export const MainScreen = createBottomTabNavigator({
    MainTabScreen: { MainTabScreen}
},{
    initialRouteName: "GoodListScreen",
    headerMode: 'none',
    tabBarOptions: {

    },
})

here my MainTabScreen like

class MapScreen extends Component {
    componentDidMount(){
        this.props.navigation.addListener('willFocus', () =>{
            
        });
        this.props.navigation.addListener('didFocus', () =>{
            
        });
   }
}

here my package.json:

"react-navigation": "3.9.1", "react-navigation-redux-helpers": "^2.0.6", "react-redux": "^6.0.0", "redux": "^4.0.0", "redux-persist": "^5.10.0", "redux-saga": "0.16.0", "reduxsauce": "1.0.1",

king804 avatar May 14 '19 02:05 king804

+1

odraude7 avatar May 15 '19 11:05 odraude7

Fixed?

king804 avatar Jun 03 '19 06:06 king804

I have found out there is a solution for those listeners https://github.com/react-navigation/redux-helpers/issues/53#issuecomment-492942942

m1r4s avatar Jun 10 '19 07:06 m1r4s

@king804 @lalithnarayan @odraude7 @m1r4s This should be already fixed in #273

bencergazda avatar Jul 08 '19 08:07 bencergazda

+1

liuhong1happy avatar Jul 09 '19 03:07 liuhong1happy