'ReactNative: _.native.createNavigationContainerRef is undefined

in my react-native app I'm trying to navigate from App.js where navigation is not yet ready, so I try to follow navigation docs:

https://reactnavigation.org/docs/navigating-without-navigation-prop/

I copied example code as it is but I'm getting the following error:

_.native.createNavigationContainerRef is not a function / undefined

//RootNavigation

import { createNavigationContainerRef } from '@react-navigation/native';

export const navigationRef = createNavigationContainerRef()

export function navigate(name, params) {
  if (navigationRef.isReady()) {
    navigationRef.navigate(name, params);
  }
}

//App.js

import { NavigationContainer } from '@react-navigation/native';
import { navigationRef } from './RootNavigation';

export default function App() {
  return (
    <NavigationContainer ref={navigationRef}>{/* ... */}</NavigationContainer>
  );
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source