I'm using Eslint in my React Native project, and in this code:
export default class AuthLoadingScreen extends React.Component {
constructor() {
super();
this.bootstrapAsync();
}
bootstrapAsync = async () => {
const userToken = await AsyncStorage.getItem('userToken');
this.props.navigation.navigate(userToken ? 'App' : 'Auth');
};
render() {
return (
<View style={styles.container}>
<ActivityIndicator />
<StatusBar barStyle="default" />
</View>
);
}
}
Eslint given a warning: "Must use destructuring props assignment". I've tried to change assignment to
const navigation = this.props;
navigation.navigate(userToken ? 'App' : 'Auth');
But it gives an error: "undefined is not an object"
EDIT: changed the constructor to:
constructor(props) {
super(props);
this.bootstrapAsync(props);
}
now code runs without errors