<div className="dm-inbox-item__project">{props.message.project}</div>
I am trying to set out the propTypes within a stateless component, and wish to define propTypes for the properties on message. Currently, I have only been successful in defining the whole message.
InboxItem.propTypes = {
message: PropTypes.string.isRequired,
};
I would like to do something like the below in order to validate individually.
Inbox.propTypes = {
message.project: Proptypes.string.isRequired,
};
Any thoughts would be appreciated.
You can do that with React.PropTypes.shape.
Inbox.propTypes = {
message: React.PropTypes.shape({
project: React.PropTypes.string.isRequired
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With