How to use the bool function from prop-types

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

201
202
203
204
205
206
207
208
209

However, code like this will not work with the `prop-types` package:

```js
// Will not work with `prop-types` package!
var errorOrNull = PropTypes.bool(42, 'myProp', 'MyComponent', 'prop');
```

It will throw an error:
fork icon388
star icon0
watch icon3

+ 3 other calls in file

180
181
182
183
184
185
186
187
188
189
  );
};

User.propTypes = {
  user: PropTypes.shapeImmutable({
    isLoading: PropTypes.bool.isRequired,
    data: PropTypes.shape({
      name: PropTypes.string.isRequired,
      age: PropTypes.number,
      birthdate: PropTypes.string,
fork icon388
star icon0
watch icon3

+ 3 other calls in file

225
226
227
228
229
230
231
232
233
234
  target: _propTypes.string,
  separator: _propTypes.string,
  filename: _propTypes.string,
  uFEFF: _propTypes.bool,
  onClick: _propTypes.func,
  asyncOnClick: _propTypes.bool
};

var defaultProps = exports.defaultProps = {
  separator: ',',
fork icon261
star icon1
watch icon2

223
224
225
226
227
228
229
230
231
232
  data: (0, _propTypes.oneOfType)([_propTypes.string, _propTypes.array]).isRequired,
  headers: _propTypes.array,
  target: _propTypes.string,
  separator: _propTypes.string,
  filename: _propTypes.string,
  uFEFF: _propTypes.bool
};

var defaultProps = exports.defaultProps = {
  separator: ',',
fork icon261
star icon0
watch icon2

302
303
304
305
306
307
308
309
310
311
  viewScroll: /*#__PURE__*/propTypes.oneOf(['auto', 'close', 'initial']),
  submenuOpenDelay: propTypes.number,
  submenuCloseDelay: propTypes.number,
  portal: /*#__PURE__*/propTypes.oneOfType([propTypes.bool, /*#__PURE__*/propTypes.exact({
    target: propTypes.object,
    stablePosition: propTypes.bool
  })]),
  theming: propTypes.string,
  onItemClick: propTypes.func
});
fork icon48
star icon883
watch icon6

+ 14 other calls in file

35
36
37
38
39
40
41
42
43
44
key: 'render',
value: function render() {
	var propTypes = {
		site: PropTypes.shape({
			running: PropTypes.bool.isRequired,
			loading: PropTypes.bool.isRequired,
			disconnected: PropTypes.bool,
			prevOutput: PropTypes.array,
			prevError: PropTypes.string,
			hasOutput: PropTypes.bool,
fork icon7
star icon42
watch icon4

44
45
46
47
48
49
50
51
52
53
  title: stringType,
  formItems: PropTypes.arrayOf(PropTypes.shape({
    label: stringType,
    mdTitle: PropTypes.string,
    type: PropTypes.oneOf(['textarea', 'version', 'code', 'input']).isRequired,
    required: PropTypes.bool
  }))
})

const configPropTypes = {
fork icon0
star icon4
watch icon2

72
73
74
75
76
77
78
79
80
81
82
   * this is essentially children. However we can't use children because then
   * using `wrapper.setProps({ children })` would work differently if this component
   * would be the root.
   */
  __element: PropTypes.element.isRequired,
  __strict: PropTypes.bool.isRequired
} : void 0;
var warnedOnce = false; // Generate an enhanced mount function.


function createMount() {
fork icon0
star icon3
watch icon1

+ 3 other calls in file

1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
left: PropTypes.number,
right: PropTypes.number,
top: PropTypes.number,
scrollFocusedIntoView: PropTypes.bool,
isLoading: PropTypes.bool,
isOpened: PropTypes.bool.isRequired,
onSelect: PropTypes.func,
ignoreAccents: PropTypes.bool,
customSuggestionsContainer: PropTypes.func,
containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
fork icon0
star icon0
watch icon3

+ 11 other calls in file

1304
1305
1306
1307
1308
1309
1310
1311
1312
* DropdownContext
* {
*  toggle: PropTypes.func.isRequired,
*  isOpen: PropTypes.bool.isRequired,
*  direction: PropTypes.oneOf(['up', 'down', 'start', 'end']).isRequired,
*  inNavbar: PropTypes.bool.isRequired,
*  disabled: PropTypes.bool
* }
*/
fork icon0
star icon0
watch icon1

+ 2 other calls in file

4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
  d_attributes: PropTypes.object.isRequired,
  d_key: PropTypes.string.isRequired,
  d_role: PropTypes.string.isRequired,
  d_tabIndex: PropTypes.string.isRequired,
  d_tag: PropTypes.any.isRequired,
  isOpen: PropTypes.bool.isRequired,
  children: PropTypes.node.isRequired,
  d_classes: PropTypes.string
};
DropdownMenuProComponent.defaultProps = {
fork icon0
star icon0
watch icon1

+ 369 other calls in file

993
994
995
996
997
998
999
1000
1001
1002
1003
        censored: PropTypes.bool,
        censoredByAdmin: PropTypes.bool,
        censoredByCommunity: PropTypes.bool,
        message: PropTypes.string,
        deleted: PropTypes.bool,
        reshareable: PropTypes.bool
    })
};


Preview.defaultProps = {
fork icon0
star icon0
watch icon1

100
101
102
103
104
105
106
107
108
109
110
    name: PropTypes.string,
    onChange: PropTypes.func,
    onSetValue: PropTypes.func,
    showErrors: PropTypes.bool,
    updateOnBlur: PropTypes.bool,
    updateOnChange: PropTypes.bool
};


const phoneValidationHOC = validationHOCFactory({
    isPhone: <intl.FormattedMessage id="teacherRegistration.validationPhoneNumber" />
fork icon0
star icon0
watch icon1

27
28
29
30
31
32
33
34
35
36
class App extends React.Component {
  static get propTypes() {
    return Object.assign({}, CustomizationOptionUrlPropTypes, HostSettingsUrlPropTypes, {
      customizationOptions: ConfigurationType,
      hostSettings: PropTypes.object.isRequired,
      internalPreview: PropTypes.bool.isRequired,
      selectWidget: PropTypes.func.isRequired,
      selectedWidget: WidgetType,
      selectedWidgetQuery: PropTypes.string,
      setCustomizationOption: PropTypes.func.isRequired,
fork icon0
star icon0
watch icon1

+ 7 other calls in file

400
401
402
403
404
405
406
407
408
409
410
    }
  }
}


FormControls.propTypes =
  { createButton: PropTypes.bool
  , perspective: PropTypes.shape( SerialisedPerspective ).isRequired
  , contextinstance: PropTypes.string.isRequired
  , roleinstance: PropTypes.string
  , myroletype: PropTypes.string.isRequired
fork icon0
star icon0
watch icon1

+ 2 other calls in file

186
187
188
189
190
191
192
193
194
195
196
197
}


TableControls.contextType = PSContext;


TableControls.propTypes =
  { createButton: PropTypes.bool.isRequired
  , perspective: PropTypes.shape( SerialisedPerspective ).isRequired
  // This is the row that is selected in the table, possibly none.
  , selectedroleinstance: PropTypes.string
  };
fork icon0
star icon0
watch icon1

+ 2 other calls in file

395
396
397
398
399
400
401
402
403
404
  title: PropTypes.string,
  links: PropTypes.arrayOf(PropTypes.shape({
    to: PropTypes.string.isRequired,
    name: PropTypes.string.isRequired
  })).isRequired,
  bullets: PropTypes.bool
};
LinkList.defaultProps = {
  bullets: false
};
fork icon0
star icon0
watch icon0

+ 11 other calls in file

68
69
70
71
72
73
74
75
76
77
  onChange: PropTypes.func,
  id: PropTypes.string.isRequired,
  name: PropTypes.string.isRequired,
  value: PropTypes.string.isRequired,
  label: PropTypes.node,
  nonsensitive: PropTypes.bool
}


module.exports = RadioBlock
fork icon0
star icon0
watch icon0