Skip to content

Commit 26ec150

Browse files
committed
initial setup
1 parent 40987e6 commit 26ec150

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

src/app/components/Main.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react";
2+
3+
export class Main extends React.Component {
4+
render() {
5+
return (
6+
<div>
7+
<div className="row">
8+
<div className="col-xs-12">
9+
<h1>The Main Page</h1>
10+
</div>
11+
</div>
12+
<div className="row">
13+
<div className="col-xs-12">
14+
<button
15+
className="btn btn-primary"
16+
onClick={() => this.props.changeUsername('Anna')}>Change the Username</button>
17+
</div>
18+
</div>
19+
</div>
20+
);
21+
}
22+
}

src/app/components/User.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react";
2+
3+
export class User extends React.Component {
4+
render() {
5+
return (
6+
<div>
7+
<div className="row">
8+
<div className="col-xs-12">
9+
<h1>The User Page</h1>
10+
</div>
11+
</div>
12+
<div className="row">
13+
<div className="col-xs-12">
14+
<p>User Name: {this.props.username}</p>
15+
</div>
16+
</div>
17+
</div>
18+
);
19+
}
20+
}

src/app/index.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
import React from "react";
22
import {render} from "react-dom";
3+
4+
import { User } from './components/User';
5+
import { Main } from './components/Main';
6+
37
class App extends React.Component {
8+
constructor() {
9+
super();
10+
this.state = {
11+
username: "Max"
12+
};
13+
}
14+
15+
changeUsername(newName) {
16+
this.setState({
17+
username: newName
18+
});
19+
}
20+
421
render() {
522
return (
6-
<h1>Hello Redux World!</h1>
23+
<div className="container">
24+
<Main changeUsername={this.changeUsername.bind(this)}/>
25+
<User username={this.state.username}/>
26+
</div>
727
);
828
}
929
}

0 commit comments

Comments
 (0)