I'm trying to get initial state in the same format as onStateChange prop provides in NavigationContainer. onStateChange doesn't fire on initial render. In the example below, I managed to get state when navigating between screens, but not on the first one. Any ideas?
export default function App() {
const [pageState, setPageState] = React.useState();
return (
<NavigationContainer onStateChange={(state) => setPageState(state)}>
<RootNavigation />
</NavigationContainer>
);
}
CodePudding user response:
Try using the onReady method from the NavigationContainer From the docs: https://reactnavigation.org/docs/navigation-container#onready