-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContact.js
49 lines (45 loc) · 1.1 KB
/
Contact.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
44
45
46
47
48
49
import React from 'react';
import ReactDOM from 'react-dom';
class Contact extends React.Component {
constructor(props) {
super(props);
this.state = {
password: 'swordfish',
authorized: false
};
this.authorize = this.authorize.bind(this);
}
authorize(e) {
const password = e.target.querySelector(
'input[type="password"]').value;
const auth = password == this.state.password;
this.setState({
authorized: auth
});
}
render() {
const login = (<form action="#" onSubmit={this.authorize}>
<input type="password" placeholder="Password" />
<input type="submit" />
</form>)
const contactInfo = (
<ul>
<li>
</li>
<li>
555.555.5555
</li>
</ul>);
return (
<div id="authorization">
<h1>{this.state.authorized ? 'Contact':'Enter the Password'}</h1>
{this.state.authorized ===true ? contactInfo: login}
</div>
);
}
}
ReactDOM.render(
<Contact />,
document.getElementById('app')
);