How to pass eslint check for this.props.navigation.navigate (reaction-navigation)?

I am using eslint airbnb in my own project. Eslint throw input error if I did not confirm the props, especially the props from react-navigation.

account verification 1 How to check this with PropTypes?

I am trying to verify it as follows:

IntroScreen.propTypes = {
  navigation: PropTypes.shape({
    navigate: PropTypes.func,
  }),
};

but still got an error like this lint 2 error

How to transfer default details, and should I?

+4
source share
2 answers

I fix this by setting the navigation and navigation to the details.

IntroScreen.propTypes = {
  navigation: PropTypes.shape({
    navigate: PropTypes.func.isRequired,
  }).isRequired,
};

eslint forces us to provide default details if we set the details as optional. Therefore, if we set up the props, eslint will not warn you again.

+4

Dede , ( ) . , .

, :

"rules": {
     "react/prop-types": ["error", { "ignore": ["navigation"] }]
}

, , ​​ , .

+2

Source: https://habr.com/ru/post/1686935/


All Articles