Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Last active November 6, 2019 18:31
Show Gist options
  • Save sabesansathananthan/ae45f918de4e16dd900693507efa05bb to your computer and use it in GitHub Desktop.
Save sabesansathananthan/ae45f918de4e16dd900693507efa05bb to your computer and use it in GitHub Desktop.
React best practice example for propTypes.
import React, { Component } from "react";
import PropTypes from "prop-types";
class Welcome extends Component {
render() {
const { name } = this.props;
return <h1>Welcome, {name}</h1>;
}
}
Welcome.PropTypes = {
name: PropTypes.string.isRequired
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment