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 ComponentName extends React.Component {
2 render() {
3 return ;
4 }
5}
6
7export default ComponentName;
8
1class HelloMessage extends React.Component {
2 render() {
3 return (
4 <div>
5 Hello {this.props.name}
6 </div>
7 );
8 }
9}
10
11ReactDOM.render(
12 <HelloMessage name="Taylor" />,
13 document.getElementById('hello-example')
14);
1// New component class starts here:
2class Friend extends React.Component {
3 render() {
4 const friend = friends[0];
5 return (
6 <div>
7 <h1>{friend.title}</h1>
8 <img src={friend.src}/>
9 </div>
10 );
11 }
12}
1class Car extends React.Component {
2 render() {
3 return <h2>Hi, I am a Car!</h2>;
4 }
5}
6