This repository was archived by the owner on Dec 3, 2022. It is now read-only.
This repository was archived by the owner on Dec 3, 2022. It is now read-only.
navigationOptions not working correctly #30
Open
Description
I've noticed that for some reason navigationOptions aren't set correctly when using useEffect to initialize them when component mounts.
Here's a basic test scenario to reproduce this:
function TestScreen() {
const navigation = useNavigation();
useEffect(() => {
console.log('component did mount');
navigation.setParams({
test: true,
});
}, []);
return null;
}
TestScreen.navigationOptions = (screenProps) => {
console.log('navigationOptions', screenProps.navigation.state.params);
};
When this screen gets navigated to, here's what I see in logs:
navigationOptions undefined
component did mount
navigationOptions {test: true}
navigationOptions undefined
Shouldn't it be:
navigationOptions undefined
component did mount
navigationOptions {test: true}
I've also noticed that output is correct when I wrap navigation.setParams
in setTimeout
:
useEffect(() => {
setTimeout(() => {
navigation.setParams({
test: true,
});
}, 0);
}, []);
Metadata
Metadata
Assignees
Labels
No labels