Monday, May 20, 2024
139
rated 0 times [  145] [ 6]  / answers: 1 / hits: 16880  / 7 Years ago, sat, october 21, 2017, 12:00:00

React Navigation's introduction page suggests the use of the following destructuring assignment:


const { navigate } = this.props.navigation;

However, when I implemented React Navigation in my App, ESLint is complaining about this line describing these both errors:



'navigation' is missing in props validation (react/prop-types)


'navigation.navigation' is missing in props validation (react/prop-types)



Even though the app seems to be working as intended, how would it be possible to remove these error lines?


More From » react-native

 Answers
17

One option is to add the propTypes prop to the component.



Example



LoginScreen.propTypes = {
navigation: PropTypes.object.isRequired,
};


Another option is to disable eslint for that page and rule. More info here




Rule Options



This rule can take one argument to ignore some specific props during
validation.



...
react/prop-types: [<enabled>, { ignore: <ignore>, customValidators: <customValidator> }]
...


[#56157] Thursday, October 19, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lailab

Total Points: 706
Total Questions: 102
Total Answers: 95

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;