1.1.0 • Published 8 years ago

proptypes v1.1.0

Weekly downloads
25,593
License
BSD
Repository
github
Last release
8 years ago

proptypes

React's PropTypes, packaged up as a standalone module.

DISCLAIMER: This is literally copied from the React 0.14 codebase. If you're using PropTypes with React, it would be silly to reference this standalone version.

Usage

function check(props, propTypes) {
  for (let prop in propTypes) {
    if (propTypes.hasOwnProperty(prop)) {
      let err = propTypes[prop](props, prop, 'name', 'prop');
      if (err) {
        console.warn(err);
        return false;
      }
    }
  }
  return true;
}

let valid = check({
  a: 42,
  b: 'News'
}, {
  a: PropTypes.number,
  b: PropTypes.oneOf(['News', 'Photos'])
});

valid;  // true

Production build

Disabling

With webpack:

module.exports = {
  resolve: {
    alias: {
      proptypes: 'proptypes/disabled',
    }
  }
};

Removing the definitions with React

When you are using this package with React like API, you might want to save bandwidth by removing the definitions. You can use babel-plugin-transform-react-remove-prop-types for that use case, for instance:

// In
const Baz = (props) => (
  <div {...props} />
);

Baz.propTypes = {
  className: PropTypes.string
};

// Out
const Baz = (props) => (
  <div {...props} />
);

License

BSD

react-ts-starterkit-mdfz-desk@hwll/hyper-unlimited-powereslint-plugin-jsx-a11y-div-fiftyeslint-plugin-jsx-a11y-div-fiftyeighteslint-plugin-jsx-a11y-div-fiftyfiveeslint-plugin-jsx-a11y-div-fiftynineeslint-plugin-jsx-a11y-div-fiftyoneeslint-plugin-jsx-a11y-div-fiftyseveneslint-plugin-jsx-a11y-div-fiftysixeslint-plugin-jsx-a11y-div-fiftythreeeslint-plugin-jsx-a11y-div-fiftytwoeslint-plugin-jsx-a11y-div-fourtyeighteslint-plugin-jsx-a11y-div-fourtyfiveeslint-plugin-jsx-a11y-div-fourtynineeslint-plugin-jsx-a11y-div-fourtyseveneslint-plugin-jsx-a11y-div-fourtysixeslint-plugin-jsx-a11y-div-sixtynineeslint-plugin-jsx-a11y-div-sixtyoneeslint-plugin-jsx-a11y-div-sixtyseveneslint-plugin-jsx-a11y-div-sixtysixeslint-plugin-jsx-a11y-div-sixtythreeeslint-plugin-jsx-a11y-div-sixtytwoeslint-plugin-jsx-a11y-div-seventyeslint-plugin-jsx-a11y-div-seventyoneeslint-plugin-jsx-a11y-div-sixtyeslint-plugin-jsx-a11y-div-sixtyeigtheslint-plugin-jsx-a11y-div-sixtyfiveeslint-plugin-jsx-a11y-div-sixtyfourreact-passcode@infinitebrahmanuniverse/nolb-prop@everything-registry/sub-chunk-2483window-weatherstorybook-addon-interactionvelocity-inferno@doodle3d/react-infinite-scroller@doodle3d/redux-prompt@butterjs/weblbs-react-tableug_babitimefflogo@alexcambose/react-infinite-scrollzap-button-libyoupwnview-checkoutunbxd-reactsearch@hamed-attar/formidable@hammerframework/hammer-web@hammerframework/web@humblejs/spinner@exoplay/exobot@northosts/cmpmezemimir-uiouiouireact-native-image-carousel-ksreact-atlas-corereact-dependency-injectionreact-css-iconsrn-search-filterreact-element-queryreact-native-action-barsb-carouselreact-native-animated-typewriterreact-loadable-libraryreact-imported-librarypzgps-preactpreact-limeappreactwiki-componentsreact-grid-libnode-easypostpinvpreact-compat-blahsimple-react-componentsshared-web-componentsinferno-animate-cssinferno-animate.cssinferno-outside-click-handlerinferno4-velocityinferno4-animate-csshrnet-react-modal-ismaseologin-react-testlogin-npm-testl4n-server@yui540/react-message-modalagile-factory-react-scripts-tempa1-reduxaddress-widgetaddress-widget-npanimate.css-reactappnexus-cmpcustom-modal-librarybotman-web-widgetdope-componentsenzyme-adapter-preacterised-mirrorfluxthis
1.1.0

8 years ago

1.0.0

8 years ago

0.14.4

8 years ago

0.14.3

9 years ago

0.14.2

9 years ago

0.14.1

10 years ago

0.14.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago