Last active
November 6, 2019 18:31
-
-
Save sabesansathananthan/ae45f918de4e16dd900693507efa05bb to your computer and use it in GitHub Desktop.
React best practice example for propTypes.
This file contains hidden or 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
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