JavaScript MIT

prop-types-exact

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

L

ljharb

Dernière activité 30 avr. 2026
ljharb/prop-types-exact

237

étoiles

7

forks

1

issues ouvertes

Ce README est souvent en anglais.

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

Projets similaires

Custom React PropType validators

JavaScript
Lljharb
663 étoiles49

A simple parser for react properties defined in typescript instead of propTypes.

TypeScript
Sstyleguidist
1,3 k étoiles260

The Select Component for React.js

TypeScript
JJedWatson
28 k étoiles4,1 k