How to use the instanceOf function from prop-types

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

122
123
124
125
126
127
128
129
130
131
propTypes: {
  ...ScrollView.propTypes,
  /**
   * An instance of [ListView.DataSource](docs/listviewdatasource.html) to use
   */
  dataSource: PropTypes.instanceOf(ListViewDataSource).isRequired,
  /**
   * (sectionID, rowID, adjacentRowHighlighted) => renderable
   *
   * If provided, a renderable component to be rendered as the separator
fork icon481
star icon0
watch icon231

87
88
89
90
91
92
93
94
95
96
// see https://github.com/facebook/react/blob/HEAD/packages/shared/isValidElementType.js
optionalElementType: PropTypes.elementType,

// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
optionalMessage: PropTypes.instanceOf(Message),

// You can ensure that your prop is limited to specific values by treating
// it as an enum.
optionalEnum: PropTypes.oneOf(['News', 'Photos']),
fork icon388
star icon0
watch icon59

+ 3 other calls in file

91
92
93
94
95
96
97
98
99
100

Router.propTypes = {
    className: PropTypes.string,
    onPathNotMatch: PropTypes.func,
    viewsConfig: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.exact({
        regexp: PropTypes.instanceOf(RegExp).isRequired,
        urlParamsNames: PropTypes.arrayOf(PropTypes.string).isRequired,
        component: PropTypes.elementType.isRequired
    }))).isRequired
};
fork icon129
star icon502
watch icon31

14
15
16
17
18
19
20
21
22
23
24
25
    }
  }
}


DateTime.propTypes = {
  value: PropTypes.instanceOf(Date),
  timeZone: PropTypes.string
};


export default DateTime;
fork icon0
star icon1
watch icon0

8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
  locale: PropTypes.string,
  format: PropTypes.string,
  tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  className: PropTypes.string,
  getValue: PropTypes.func,
  value: PropTypes.instanceOf(Date)
};
DatePicker.defaultProps = {
  theme: {},
  tag: 'div',
fork icon0
star icon0
watch icon1

+ 4 other calls in file

27
28
29
30
31
32
33
34
35
36
});

const videoBase = module.exports.videoBase = exact({
  title: PropTypes.string.isRequired,
  video_number: PropTypes.number.isRequired,
  date: PropTypes.instanceOf(Date).isRequired,
  video_id: PropTypes.string,
  live_example: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.oneOf([false]),
fork icon0
star icon0
watch icon2