-
Notifications
You must be signed in to change notification settings - Fork 50k
Description
const Foo = ({ onAction }) => <div onClick={onAction} />;
Foo.propTypes = {
onAction: PropTypes.function
};
const Bar = () => <Foo onaction={() => console.log('action')} />; // This should warnWe currently don't warn for properties that don't exist in the propTypes set. I.e. we don't catch typos. This is mostly a legacy artifact and there are many components out there that don't define their full set of props. E.g. when ... spread is used. Few components also define the children prop even though they use it. Warning for all of these might be too much work initially.
However, we can start small. We can find missing properties that have corresponding properties with a different case and suggest that the developer use that instead. This is essentially always a bug.
While it is technically possible to have the same property name with two or more different case, it is considered bad practice to allow both. It causes overhead to test for both in the diffing/rendering. It causes style-guide issues where people have to pick which style to use. It also makes it worth for tooling where search/replace can easily miss less commonly used variants. That's why React only allows a single case, and ideally so should custom components.