React linter airbnb proptypes array

FacundoGFlores picture FacundoGFlores · Jan 20, 2017 · Viewed 25.1k times · Source

I have the following PropTypes:

SmartTable.propTypes = {
  name: React.PropTypes.string.isRequired,
  cols: React.PropTypes.array.isRequired,
  rows: React.PropTypes.array.isRequired,
};

but the linter says me:

Prop type array is forbidden, how can I change it?

Answer

FacundoGFlores picture FacundoGFlores · Jan 20, 2017

A possible solution for this (but I think it is not smart):

SmartTable.propTypes = {
  name: React.PropTypes.string.isRequired,
  cols: React.PropTypes.arrayOf(React.PropTypes.string),
  rows: React.PropTypes.arrayOf(React.PropTypes.string),
};