使用纯渲染函数PropTypes eslint错误

时间:2016-11-21 23:01:27

标签: javascript reactjs eslint

我有以下纯渲染组件:

ExtentHeight

但我在eslint中遇到以下错误:

import React, { PropTypes } from 'react';
import Dropzone from 'react-dropzone';

export const renderDropzone = ({ name, input: { onChange } }) => {
  return (
    <div>
      <Dropzone
          name={name}
          onDrop={filesToUpload => onChange(filesToUpload)}
      />
      <button type="button" className="button">Upload</button>
    </div>
  );
};

renderDropzone.PropTypes = {
  name: PropTypes.string.isRequired,
  input: PropTypes.object.isRequired
};

1 个答案:

答案 0 :(得分:3)

只是一个错字:

renderDropzone.PropTypes = {
  name: PropTypes.string.isRequired
};

应该是:

renderDropzone.propTypes = {
  name: PropTypes.string.isRequired
};

(小写&#39; p&#39;在类属性上)