Last active
May 30, 2016 08:39
-
-
Save tuchk4/7c5bac6bc2662165435bfa6cdb234730 to your computer and use it in GitHub Desktop.
PropTypes for stateless components. Would be great If static keyword inside function block - is a link to function object (constructor). So we can write as at the first example.
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
export default (props) => { | |
// this is not possible, but I think this is more readable that next example | |
static propTypes = { | |
name: PropsTypes.string.requried | |
}; | |
return <Div>{props.name}</Div>; | |
} |
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
const Name =function(props) { | |
return <Div>{props.name}</Div>; | |
} | |
Name.propTypes = { | |
name: PropsTypes.string.requried | |
}; | |
export deafult Name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
static props/methods definition available only for classes