Created
May 28, 2019 10:40
-
-
Save tommmyy/796f3566ae12bb977bc2b65d726c56ea to your computer and use it in GitHub Desktop.
Extending component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEFORE: | |
const CommentTextArea = ({ maxCharacters, name, validate, ...otherProps }) => ( | |
<TextareaField | |
name={name} | |
rows={4} | |
label={<Message {...messages.comment} />} | |
maxCharacters={maxCharacters} | |
{...otherProps} | |
/> | |
); | |
CommentTextArea.propTypes = { | |
maxCharacters: PropTypes.number, | |
name: PropTypes.string, | |
}; | |
CommentTextArea.defaultProps = { | |
maxCharacters: 256, | |
name: 'comment', | |
}; | |
// AFTER: | |
const CommentTextArea = props => <TextareaField {...props} />; | |
CommentTextArea.propTypes = { | |
maxCharacters: PropTypes.number, | |
name: PropTypes.string.isRequired, | |
rows: PropTypes.number, | |
}; | |
CommentTextArea.defaultProps = { | |
maxCharacters: 256, | |
rows: 4, | |
label: <Message {...messages.comment} />, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment