React-native-navigation: [Android] registerComponentDidAppearListener not triggering (sometimes) on functional components (release mode)

Created on 30 Jun 2019  路  8Comments  路  Source: wix/react-native-navigation

Issue Description

If you use a functional (with hooks) component for a screen and you use registerComponentDidAppearListener you could end up with the events not being triggered (only on Android and in release mode)

Steps to Reproduce / Code Snippets / Screenshots

I have created a simple react-native project on a public repo to reproduce it. The example reproduce the DidAppear not working on Android release mode only

The project includes a screen implemented as a Functional Component (with hooks) and also a PureComponent with the same behavior.

On Android (Debug Mode)

react-native run-android
The sample works perfect on both Functional and PureComponent

On Android (Release Mode)

react-native run-android --variant=release
The sample works perfect on the PureComponent implementation but the Functional doesn't work

ezgif-2-c6b40be6fbf1
Video of the example app running in release mode


Environment

  • React Native Navigation version: 2.22.1
  • React Native version: 0.59.9
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator and Device (Only Release Mode)

Most helpful comment

@sintylapse mentioned here https://github.com/underscopeio/react-native-navigation-hooks/issues/7 the cause of the events not being triggered.

Basically you must use useLayoutEffect instead of useEffect 馃殌

BTW I just published a new version of react-native-navigation-hooks which includes this fix

All 8 comments

@guyca Any updates on this issue?

Also seems like life cycle hook is pretty slow on Android and I am testing the App on Samsung S10 so can't be the device is slow. Furthermore on iOS seems everything smooth.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

The issue is still happening it would be awesome if someone can take a look into.

There's a I have simple react-native project to reproduce de issue here -> https://github.com/jpgarcia/rnn-events-issue

Looks like life cycle hook is not guarantee to get fire on Debug build too. It's still happening:(

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

Hey @guyca do you have any updates on this issue? Thanks!

@sintylapse mentioned here https://github.com/underscopeio/react-native-navigation-hooks/issues/7 the cause of the events not being triggered.

Basically you must use useLayoutEffect instead of useEffect 馃殌

BTW I just published a new version of react-native-navigation-hooks which includes this fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhanguangao picture zhanguangao  路  3Comments

viper4595 picture viper4595  路  3Comments

birkir picture birkir  路  3Comments

edcs picture edcs  路  3Comments

no23reason picture no23reason  路  3Comments