1.1.0 • Published 7 years ago

proptypes v1.1.0

Weekly downloads
25,593
License
BSD
Repository
github
Last release
7 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-2483@doodle3d/react-infinite-scroller@doodle3d/redux-prompt@exoplay/exobot@humblejs/spinner@hammerframework/web@hammerframework/hammer-web@hamed-attar/formidableenzyme-adapter-preacterised-mirrorfluxthisreact-native-image-carousel-ksreact-loadable-libraryreact-native-action-barreact-native-animated-typewriterlbs-react-tablelogin-npm-testlogin-react-test@northosts/cmpbotman-web-widgetappnexus-cmpanimate.css-reactagile-factory-react-scripts-temp@yui540/react-message-modala1-reduxaddress-widgetaddress-widget-npcustom-modal-librarydope-componentsinferno-animate-cssinferno-animate.cssinferno4-animate-cssinferno4-velocityinferno-outside-click-handlerreactwiki-componentsrn-search-filtersb-carousell4n-servershared-web-componentssimple-react-componentsstorybook-addon-interactiontimefflogonode-easypostview-checkoutmimir-uimezevelocity-infernoug_babiunbxd-reactsearchwindow-weatherpreact-limeapppreact-compat-blahouiouipinvyoupwnpzgps-preactzap-button-libreact-css-iconsreact-dependency-injectionreact-element-queryreact-atlas-corereact-grid-libreact-imported-library@alexcambose/react-infinite-scroll@butterjs/web
1.1.0

7 years ago

1.0.0

7 years ago

0.14.4

7 years ago

0.14.3

8 years ago

0.14.2

8 years ago

0.14.1

8 years ago

0.14.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago