Use of PropType in React component

In a React component, we can pass the properties from higher-level component, so knowledge of properties is a must, as it will give you more flexibility to extend your component and saves your time:

MyComponent.propTypes = { 
isLoading: PropTypes.bool.isRequired,
items: ImmutablePropTypes.listOf(
ImmutablePropTypes.contains({
name: PropTypes.string.isRequired,
})
).isRequired
}

You can also validate your properties the way we can validate properties of Immutable JS with react immutable proptypes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset