Skip to content

Instantly share code, notes, and snippets.

@aerrity
Created January 30, 2018 21:49
Show Gist options
  • Select an option

  • Save aerrity/354767350acf749dbcc74728f4735d37 to your computer and use it in GitHub Desktop.

Select an option

Save aerrity/354767350acf749dbcc74728f4735d37 to your computer and use it in GitHub Desktop.
Components - function vs. class syntax
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