Created
January 30, 2018 21:49
-
-
Save aerrity/354767350acf749dbcc74728f4735d37 to your computer and use it in GitHub Desktop.
Components - function vs. class syntax
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 from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| function ModuleTitle(props) { | |
| return <h1>Welcome to the {props.name} module.</h1>; | |
| } | |
| // class ModuleTitle extends React.Component { | |
| // render() { | |
| // return <h1>Welcome to the {this.props.name} module.</h1>; | |
| // } | |
| // } | |
| const element = <ModuleTitle name="Advanced JavaScript" />; | |
| ReactDOM.render( | |
| element, | |
| document.getElementById('root') | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment