Skip to content

Instantly share code, notes, and snippets.

@tuchk4
Last active May 30, 2016 08:39
Show Gist options
  • Save tuchk4/7c5bac6bc2662165435bfa6cdb234730 to your computer and use it in GitHub Desktop.
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.
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>;
}
const Name =function(props) {
return <Div>{props.name}</Div>;
}
Name.propTypes = {
name: PropsTypes.string.requried
};
export deafult Name;
@tuchk4
Copy link
Author

tuchk4 commented May 30, 2016

Which example is better and more readable?)

@tuchk4
Copy link
Author

tuchk4 commented May 30, 2016

static props/methods definition available only for classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment