File tree Expand file tree Collapse file tree 1 file changed +40
-10
lines changed
Expand file tree Collapse file tree 1 file changed +40
-10
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,45 @@ import ReactDOM from 'react-dom';
44
55import Password from '../../src' ;
66
7- const Root = ( ) => (
8- < div >
9- < Password
10- uppercase
11- lowercase
12- digits
13- onChange = { ( valid , password ) => { console . log ( valid , password ) } }
14- />
15- </ div >
16- ) ;
7+ class Root extends React . Component {
8+ constructor ( ) {
9+ super ( ) ;
10+ this . state = {
11+ passwordValid : false ,
12+ password : '' ,
13+ } ;
14+
15+ this . handleOnChange = this . handleOnChange . bind ( this ) ;
16+ }
17+
18+ handleOnChange ( passwordValid , password ) {
19+ this . setState ( {
20+ passwordValid,
21+ password,
22+ } ) ;
23+ }
24+
25+ renderPasswordValidity ( ) {
26+ return this . state . passwordValid ?
27+ < span style = { { color : 'green' } } > Valid</ span > :
28+ < span style = { { color : 'red' } } > Invalid</ span >
29+ }
30+
31+ render ( ) {
32+ return (
33+ < div >
34+ < Password
35+ uppercase
36+ lowercase
37+ digits
38+ onChange = { this . handleOnChange }
39+ />
40+ < div >
41+ The password text is < b > { this . state . password } </ b > and it is { this . renderPasswordValidity ( ) } password
42+ </ div >
43+ </ div >
44+ )
45+ }
46+ }
1747
1848ReactDOM . render ( < Root /> , document . getElementById ( 'app' ) ) ;
You can’t perform that action at this time.
0 commit comments