Skip to content

Commit ae439fd

Browse files
authored
Merge pull request #1 from linuxuser07/basics
Basics
2 parents 1770010 + 9790dd9 commit ae439fd

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

react-complete-guide/src/App.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
import React, { Component } from 'react';
22
import './App.css';
3+
import Person from './Person/Person';
34

45
class App extends Component {
6+
state = {
7+
persons: [
8+
{name: 'Max', age: 28},
9+
{name: 'Manu', age: 29},
10+
{name: 'Stephanie', age: 26}
11+
]
12+
}
13+
514
render() {
615
return (
716
<div className="App">
817
<h1>Hi, I'm a react app </h1>
18+
<p>This is really working </p>
19+
<button>Switch Name</button>
20+
<Person name={this.state.persons[0].name} age={this.state.persons[0].age}/>
21+
<Person name={this.state.persons[1].name} age={this.state.persons[1].age}> My Hobbies: Racing</Person>
22+
<Person name={this.state.persons[2].name} age={this.state.persons[2].age}/>
923
</div>
1024
);
25+
//this is what the jsx is compile to
26+
//return React.createElement('div', {className: 'App'}, React.createElement('h1', null, 'this does work'));
1127
}
1228
}
1329

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
3+
const person = (props) => {
4+
return (
5+
<div>
6+
<p>I'm {props.name} and I am {props.age} years old!</p>
7+
<p>{props.children}</p>
8+
</div>
9+
)
10+
}
11+
12+
export default person;

0 commit comments

Comments
 (0)