How to use the checkPropTypes function from prop-types

Find comprehensive JavaScript prop-types.checkPropTypes code examples handpicked from public code repositorys.

208
209
210
211
212
213
214
215
216

It will throw an error:

```
Calling PropTypes validators directly is not supported by the `prop-types` package.
Use PropTypes.checkPropTypes() to call them.
```

(If you see **a warning** rather than an error with this message, please check the [above section about compatibility](#compatibility).)
fork icon388
star icon0
watch icon3

6
7
8
9
10
11
12
13
14
15
 * @return {*} component return
 */
function withPropTypeChecks (component) {
  return (props) => {
    if (component.propTypes) {
      PropTypes.checkPropTypes(
        component.propTypes,
        props,
        'prop',
        component.name
fork icon1
star icon10
watch icon2

104
105
106
107
108
109
110
111
112
program
  .command('validate')
  .description('Validate  the config.js conforms to the specification')
  .action(function () {
    const config = require(path.join(process.cwd(), 'config.js'))
    PropTypes.checkPropTypes(configPropTypes, config)
  })

program.parse(process.argv)
fork icon0
star icon4
watch icon2

7
8
9
10
11
12
13
14
15
16

const checkPropTypes = (component, props) => {
        if (process.env.NODE_ENV !== 'production' && typeof component.propTypes === 'object') {
                const name = component.displayName || component.name;

                PropTypes.checkPropTypes(component.propTypes, props, 'prop', name);
        }
};

const getProps = vnode => Object.assign({}, vnode.component.defaultProps, vnode.props);
fork icon559
star icon0
watch icon2

18
19
20
21
22
23
24
25
26
27
  shopStore: new MemoryStrategy(),
  accessMode: 'offline'
};

module.exports = function shopify(shopifyConfig) {
  PropTypes.checkPropTypes(ShopifyConfigTypes, shopifyConfig, 'option', 'ShopifyExpress');

  const config = Object.assign({}, defaults, shopifyConfig);

  return {
fork icon87
star icon0
watch icon1

42
43
44
45
46
47
48
49
50
51
  }
}

const typePropTypes = TYPES[type].propTypes;

PropTypes.checkPropTypes(typePropTypes, forwardedProps, "prop", type);

const COMPONENTS = {
  StaticCanvas: () => new StaticCanvas(ref, forwardedProps),
  Canvas: () => new Canvas(ref, forwardedProps),
fork icon0
star icon0
watch icon4