-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoot.jsx
49 lines (42 loc) · 1.03 KB
/
Root.jsx
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
/* global require, document */
import React from 'react';
import ReactDOM from 'react-dom';
import Password from '../../src';
class Root extends React.Component {
constructor() {
super();
this.state = {
passwordValid: false,
password: '',
};
this.handleOnChange = this.handleOnChange.bind(this);
}
handleOnChange(passwordValid, password) {
this.setState({
passwordValid,
password,
});
}
renderPasswordValidity() {
return this.state.passwordValid ?
<span style={{ color: 'green' }}>Valid</span> :
<span style={{ color: 'red' }}>Invalid</span>;
}
render() {
return (
<div>
<Password
uppercase
lowercase
digits
onChange={this.handleOnChange}
className="password-input"
/>
<div>
The password text is <b>{this.state.password}</b> and it is {this.renderPasswordValidity()} password
</div>
</div>
)
}
}
ReactDOM.render(<Root />, document.getElementById('app'));