I am getting route from react-native in one component as below:
const { route } = this.props;
const { fromPage } = route.params;
But sometimes the route is null 9perhaps it was not set when navigating), how to check if that is null before getting the value like above?
3
Answers
Should look at
useNavigationState
:documentation
Probably you can use a conditional statement, as I have shown below.
You can write like this:
fromPage
param has type asstring | undefined
, you can check the condition of the param before using it