How React PropTypes allow different types for one prop?
You can use oneOfType()
method of PropTypes
.
For example, the height property can be defined with either string
or number
type as below:
Component.PropTypes = {size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),};
July 11, 2022
124
Read more
What is React?
November 06, 2022
ReactJSHow to programmatically trigger click event in React?
November 06, 2022
ReactJS