-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
43 lines (33 loc) · 947 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import Clock from './Clock.js';
import ColorPicker from './ColorPicker.js';
import ValidPhoneNumber from './ValidPhoneNumber.js';
const green = '#39D1B4';
const yellow = '#FFD712';
export class App extends React.Component {
constructor(props){
super(props);
this.state = {color: green}
this.changeColor = this.changeColor.bind(this);
}
changeColor() {
const newColor = this.state.color === green ? yellow : green;
this.setState({ color: newColor });
}
render() {
return (
<div style={{background: this.state.color}}>
<h1>
Change <div> color, <i>{this.props.nimi}</i> (<- prop.name)
</h1>
<button onClick = {this.changeColor} >
Change color
</button>
<Clock name="Tom"/>
<ColorPicker />
<ValidPhoneNumber />
</div>
);
}
}
export default App;