React Components: React components are JavaScript functions.
function Welcome(props) {
return |h1>Hello {props.name}!|/h1>;
}
ReactDOM.render(|Welcome name="John Doe"/>, document.getElementById('root'));
React can also use ES6 classes to create components.
This example also creates a React component named "Welcome" with property arguments:
class Welcome extends React.Component {
render() { return(|h1>Hello {this.props.name}|/h1>); }
}
ReactDOM.render(|Welcome name="John Doe"/>, document.getElementById('root'));
References:
https://www.w3schools.com/whatis/whatis_react.asp
function Welcome(props) {
return |h1>Hello {props.name}!|/h1>;
}
ReactDOM.render(|Welcome name="John Doe"/>, document.getElementById('root'));
React can also use ES6 classes to create components.
This example also creates a React component named "Welcome" with property arguments:
class Welcome extends React.Component {
render() { return(|h1>Hello {this.props.name}|/h1>); }
}
ReactDOM.render(|Welcome name="John Doe"/>, document.getElementById('root'));
References:
https://www.w3schools.com/whatis/whatis_react.asp
No comments:
Post a Comment