Describing props with propTypes that come from a Higher order component

Viewed 347

I am using i18next (and it's package for react) and have a class component that uses withTranslation():

import React, { Component } from 'react';
import { withTranslation } from 'react-i18next';

class Home extends Component {
  constructor(props) {
    super(props);
    // some default values are set here
  }

  componentDidMount() {
    // some http requests are happening here
  }

  render() {
    const { t } = this.props;
    return (
      <h1>{t('pageHome:title')}</h1>
    );
  }
}

export default withTranslation()(Home);

I am also using airbnb: javascript style guide and I get on this line the following "error":

ESLint: t is missing in props validation (react/prop-types)

because t is available from withTranslation() HOC added to Home component.

Is that the right approach, or something can tell the linter that this prop is defined in HOC? Or am I missing completely the point of those prop types?

Home.propTypes = {
  t: PropTypes.func.isRequired,
};
0 Answers
Related