Last active
March 28, 2017 07:20
-
-
Save StevenJL/d9d5132b336857835b68 to your computer and use it in GitHub Desktop.
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
// The simplest component is a Javascript function that takes `props` | |
// as an argument and returns a React element. This is called a | |
// "functional component" since, well, it's just a function! | |
function CommentBox(props) { | |
return <div>Hello, here is a comment: {props.content} </div>; | |
} | |
// If you're using ES 6, React components can be created | |
// by extending React.Component. | |
class CommentBox extends React.Component { | |
render() { | |
return ( | |
// Note this <div> is not a DOM node, but an instance of a React div element | |
<div className="commentBox"> | |
Hello, here is a comment: {props.content} | |
</div> | |
) | |
} | |
} | |
// You can render components | |
ReactDom.render( | |
<CommentBox content="My opinion matters!"/>, | |
document.getElementId("root") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment