Skip to content

Instantly share code, notes, and snippets.

@debonx
Created January 2, 2020 19:00
Show Gist options
  • Save debonx/238441487c9edad4be5f332015554e5b to your computer and use it in GitHub Desktop.
Save debonx/238441487c9edad4be5f332015554e5b to your computer and use it in GitHub Desktop.
React: Stateless functional component example.
// Normal way to display a prop:
export class MyComponentClass extends React.Component {
render() {
return <h1>{this.props.title}</h1>;
}
}
// Stateless functional component way to display a prop:
export const MyComponentClass = (props) => {
return <h1>{props.title}</h1>;
}
// Normal way to display a prop using a variable:
export class MyComponentClass extends React.component {
render() {
let title = this.props.title;
return <h1>{title}</h1>;
}
}
// Stateless functional component way to display a prop using a variable:
export const MyComponentClass = (props) => {
let title = props.title;
return <h1>{title}</h1>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment