1.1.1 • Published 8 years ago

restrict-prop-types v1.1.1

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

restrict-prop-types

PropType warnings for extraneous props passed to the underlying component.

Usage

import React, { Component, PropTypes } from 'react';
import restrict from 'restrict-prop-types';

class DumbComponent extends Component {
  static displayName = 'Dumb';
  static propTypes = {
    b: PropTypes.number
  };
  ...
}

render(<DumbComponent a={1} b={2} c={3}/>)

'Warning: Failed propType: Invalid additional prop(s): 'a', 'c' supplied to restrict(Dumb).'

Usage as a transform

Alternatively, just put all your dumb components in the same directory, and have a .babelrc file that uses react-transform-hoc to apply restrict-prop-types to all the components.

components/.babelrc

{
  "presets": [
    "react"
  ],
  "plugins": [
    ["react-transform", {
      "transforms": [{
        "transform": "react-transform-hoc",
        "imports": [
          "restrict-prop-types"
        ]
      }]
    }]
  ]
}
1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago