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

zhanguangao picture zhanguangao  ·  3Comments

henrikra picture henrikra  ·  3Comments

swingywc picture swingywc  ·  3Comments

charlesluo2014 picture charlesluo2014  ·  3Comments

nbolender picture nbolender  ·  3Comments