1
我有以下的純渲染組件:PropTypes 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
};
但我得到的eslint以下錯誤:
4:34 error 'name' is missing in props validation react/prop-types
4:40 error 'input' is missing in props validation react/prop-types
無狀態組件的靜態屬性被稱爲'propTypes',它具有小寫字母「p」。 –