prop-types-exact

For use with React PropTypes. Will error on any prop not explicitly specified.

MIT 12 个版本
安装
npm install prop-types-exact
yarn add prop-types-exact
pnpm add prop-types-exact
bun add prop-types-exact
README

prop-types-exact Version Badge

github actions coverage License Downloads

npm badge

For use with React PropTypes. Will error on any prop not explicitly specified.

Usage

import PropTypes from 'prop-types';
import exact from 'prop-types-exact';

function Foo({ foo, bar }) {
  return <div>{foo}{bar}</div>
}
Foo.propTypes = exact({
  foo: PropTypes.string,
  bar: PropTypes.number,
});

<Foo foo="hi" bar={3} /> // no warnings

<Foo foo="hi" bar={3} baz="extra" /> // propTypes warning!

Tests

Simply clone the repo, npm install, and run npm test

版本列表
1.2.7 2024-12-29
1.2.6 2024-12-16
1.2.5 2024-07-11
1.2.4 2024-05-23
1.2.3 2024-05-23
1.2.2 2024-05-22
1.2.1 2024-05-22
1.2.0 2018-06-15
1.1.2 2018-01-17
1.1.1 2017-07-06
1.1.0 2017-06-05
1.0.0 2017-06-05