1class MyComponent extends React.Component{
2 constructor(props){
3 super(props);
4 };
5 render(){
6 return(
7 <div>
8 <h1>
9 My First React Component!
10 </h1>
11 </div>
12 );
13 }
14};
15
1class Welcome extends React.Component {
2 render() {
3 return <h1>Hello, {this.props.name}</h1>;
4 }
5}
1function Welcome(props) {
2 return <h1>Hello, {props.name}</h1>;
3}
4
5function App() {
6 return (
7 <div>
8 <Welcome name="Sara" /> <Welcome name="Cahal" /> <Welcome name="Edite" /> </div>
9 );
10}
11
12ReactDOM.render(
13 <App />,
14 document.getElementById('root')
15);