Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heap causing application to reload/refresh when native popup is shown #267

Open
rubenmaas opened this issue Oct 28, 2021 · 3 comments
Open

Comments

@rubenmaas
Copy link

Our environment

    ...
    "react-native": "0.66.0",
    "@react-navigation/bottom-tabs": "^5.11.9",
    "@react-navigation/drawer": "^5.12.5",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.4",
    "@heap/react-native-heap": "^0.16.0",
    ...

Our findings on both iOS and Android

  • Wrapping HeapNavigationContainer around the standard NavigationContainer through Heap.withReactNavigationAutotrack causes the application to refresh/reload, whenever a native popup is triggered for permissions to access native modules like the camera, photo library. We have several authentication providers that use OAuth authentication flows through async function calls with awaits to authenticate the user.

  • Jest tests fail with an error when using the provided babel configuration: Components/Touchable/TouchableNativeFeedback.js: Cannot read property 'end' of null. There are no events defined in the entire application manually (we integrated Heap following the docs for auto-capturing events).

@Dmitry-GH
Copy link

So, this issue has been live since the end of 2021 and it's still open?
Any workarounds?

@bnickel
Copy link
Collaborator

bnickel commented Sep 13, 2023

The issue is likely that Heap.withReactNavigationAutotrack is being called inside a function (likely App). Any time that App executes, HeapNavigationContainer is a new component class causing the whole navigation container to be reconstructed.

The fix is to move the definition out of the function. E.g.:

const HeapNavigationContainer = Heap.withReactNavigationAutotrack(NavigationContainer);

const App = () => {
  ...
  return (
    <HeapNavigationContainer>
      ...
    </HeapNavigationContainer>
  );
};

PR #406 is in review right now to address the issue by caching the component.

@Dmitry-GH
Copy link

@bnickel thank you so much for your investigation, your fix is working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants