⬅︎ Back to 4 different kinds of React component styles
"Is there not a way to put that Button.propTypes thing in the first React.Component style into the class??"Yes, you can put the propTypes inside the class if you're using ES6 with Babel (but you need to enable stage-0 features)Just add the following inside the classstatic propTypes = { day: PropTypes.string.isRequired, increment: PropTypes.func.isRequired,};
Thanks! I updated the blog.
Comment
"Is there not a way to put that Button.propTypes thing in the first React.Component style into the class??"
Yes, you can put the propTypes inside the class if you're using ES6 with Babel (but you need to enable stage-0 features)
Just add the following inside the class
static propTypes = {
day: PropTypes.string.isRequired,
increment: PropTypes.func.isRequired,
};
Replies
Thanks! I updated the blog.