Stemming from this: https://www.w3.org/TR/FileAPI/#file-section
So what you could do is checking if the object has a property that is name and that is a string: something like this:
const isFile = function(props, propName, componentName) {
const retVal = typeof props[propName].name == 'string';
return new Error(
`Invalid prop ${propFullName} supplied to ${componentName}. It is not a File.`
);
}
Component.propTypes = {
onClick: isFile(1)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…