jsx-eslint/eslint-plugin-react

no-unused-prop-types rule does not recognise component that returns an array

Open

#1.682 aberto em 8 de fev. de 2018

Ver no GitHub
 (6 comments) (2 reactions) (0 assignees)JavaScript (2.797 forks)batch import
enhancementhelp wantedreact 16

Métricas do repositório

Stars
 (8.630 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Example:

import React from 'react';
import PropTypes from 'prop-types';

const TestComponent = () => (
  ['one', 'two', 'three'].map(text => <div>{ text }</div>)
);

TestComponent.propTypes = {
  customClass: PropTypes.string,
};

export default TestComponent;

React 16 allows for arrays to be returned from components, but in the above example, the no-unused-prop-types seems to not recognise that customClass is unused. It does detect it when the component is changed to:

const TestComponent = () => {
  const componentArr = ['one', 'two', 'three'].map(text => <div>{ text }</div>);
  return <div>{ componentArr }</div>;
};

Guia do colaborador