React-native-navigation: Command event callback not being invoked on popping

Created on 6 Nov 2020  ยท  7Comments  ยท  Source: wix/react-native-navigation

๐Ÿ› Bug Report

  useNavigationCommand(
    useCallback(() => {
      console.debug(`${componentId} on navigation command!`);
      canNavigate.current = false;
    }, [componentId])
  );
  useNavigationCommandComplete(
    useCallback(() => {
      console.debug(`${componentId} on navigation command complete!`);
      canNavigate.current = true;
    }, [componentId])
  );

this uses the react-native-navigation-hooks package

Per docs, this command should be called on every command:

The commandListener is called whenever a _Navigation command_ (i.e push, pop, showModal etc) is invoked.

In my case, when pushing from Screen A to Screen B, the order of execution is the following:

  1. โœ… First callback is invoked
  2. โœ… Navigation animation happens
  3. โœ… Second callback is invoked

When popping from Screen B to Screen A though;

  1. โœ… First callback is invoked
  2. โœ… Navigation animation happens
  3. โŒ nothing

Have you read the Contributing Guidelines on issues?

Yes.

Platform

  • [x] iOS
  • [ ] Android (not yet tested!)
iOS acceptebug requires reproduction ๐Ÿš stale

Most helpful comment

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 version and report back. Thank you for your contributions.

All 7 comments

@mrousavy Are you listening to these commands in screen B?

@guyca I have listeners on both screens, none of them trigger on pop. ๐Ÿ˜Ÿ

@mrousavy I'm unable to reproduce in the Playground app. Please repro as this could be an issue with the hooks library or a timing issue related to component unmount.

did you try it on iOS? I'll try creating a quick repro later

Yup, tried on iOS and a global command listener.

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 version and report back. Thank you for your contributions.

The issue has been closed for inactivity.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

switchtrue picture switchtrue  ยท  3Comments

nbolender picture nbolender  ยท  3Comments

swingywc picture swingywc  ยท  3Comments

yedidyak picture yedidyak  ยท  3Comments

tmaly1980 picture tmaly1980  ยท  3Comments