expo / ex-navigation

Route-centric navigation for React Native
997 stars 201 forks source link

Can only update a mounted or mounting component using immediatelyResetStack #468

Closed bitcoinvsalts closed 7 years ago

bitcoinvsalts commented 7 years ago

I get this warning:

Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState,
 or forceUpdate on an unmounted component. This is a no-op.

when using: this.props.navigator.immediatelyResetStack([Router.getRoute("tabs")]);

but not when using: this.props.navigator.push(Router.getRoute('tabs'));

any idea why?

quanphm commented 7 years ago

maybe this.props.navigator in this.props.navigator.immediatelyResetStack is not the root navigator. I think you can try

const rootNavigator = this.props.navigation.getNavigator('root')
rootNavigator.immediatelyResetStack([Router.getRoute("tabs")])
bitcoinvsalts commented 7 years ago

thanks @mikunpham it's working good.

tiaaaa123 commented 7 years ago

I'm getting the same issue, but by using replace()

try {
      await this.props.actions.authenticate(token);
      this.props.navigator.immediatelyResetStack([Router.getRoute('tabBar')], 0);
} catch (error) {
     this.props.navigator.replace('home');
}

I have a stackNavigation ad in the initialRoute, i do this code. While it does the replace to the new route, i get the same warning as the one in this issue.

I tried @mikunpham solution, but it doesn't work. Any idea?

vincent-lu commented 7 years ago

I'm having the same problem (with 2.11.2 or 3.0.0). Short of migrating to react-navigation. Is there anything we can do?

BTW: at version 2.10.0 it worked without problem with Expo 16, but started throwing the warning when I upgraded to Expo 17 and 2.11.2.

Ping @brentvatne @skevy

Thanks.

calcazar commented 6 years ago

+1