1

I've been programming on React for about a year and I always see this react/forbid-prop-types coming, so I have this rule out: // eslint-disable-next-line react/forbid-prop-types, like:

SigninSubmitButton.propTypes = {
  signInAsync: PropTypes.func.isRequired,
  disabledProp: PropTypes.oneOfType([PropTypes.bool, PropTypes.number])
    .isRequired,
  // eslint-disable-next-line react/forbid-prop-types
  style: PropTypes.array,
};

What is the problem with those types?

1 Answer 1

1

From the docs:

By default this rule prevents vague prop types with more specific alternatives available (any, array, object)

So either type your array as its real type or turn off the rule

This rule is a formatting/documenting preference and not following it won't negatively affect the quality of your code. This rule encourages prop types that more specifically document their usage.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.