@@ -12,8 +12,8 @@ class InputTest extends React.Component {
1212 multilineRows : 'A\n\B\nC\nD\nE\nF' ,
1313 } ;
1414
15- handleChange = ( name , value ) => {
16- this . setState ( { ... this . state , [ name ] : value } ) ;
15+ handleChange = ( value , ev ) => {
16+ this . setState ( { [ ev . target . name ] : value } ) ;
1717 } ;
1818
1919 render ( ) {
@@ -23,18 +23,19 @@ class InputTest extends React.Component {
2323 < p > lorem ipsum...</ p >
2424 < Input
2525 type = "text"
26+ name = "normal"
2627 value = { this . state . normal }
27- label = "First Name" onChange = { this . handleChange . bind ( this , 'normal' ) }
28+ label = "First Name" onChange = { this . handleChange }
2829 maxLength = { 12 }
2930 />
30- < Input type = "email" value = { this . state . fixedLabel } label = "Label fixed" floating = { false } onChange = { this . handleChange . bind ( this , 'fixedLabel' ) } />
31+ < Input type = "email" name = "fixedLabel" value = { this . state . fixedLabel } label = "Label fixed" floating = { false } onChange = { this . handleChange } />
3132 < Input type = "text" value = "Read only" readOnly label = "Phone Number" />
32- < Input type = "email" value = { this . state . multilineHint } label = "Description" hint = "Enter Description" multiline onChange = { this . handleChange . bind ( this , 'multilineHint' ) } />
33- < Input type = "text" value = { this . state . multilineRows } label = "Row Limited Description" hint = "Enter Description" multiline rows = { 4 } onChange = { this . handleChange . bind ( this , 'multilineRows' ) } />
33+ < Input type = "email" name = "multilineHint" multilineHint value = { this . state . multilineHint } label = "Description" hint = "Enter Description" multiline onChange = { this . handleChange } />
34+ < Input type = "text" name = "multilineRows" value = { this . state . multilineRows } label = "Row Limited Description" hint = "Enter Description" multiline rows = { 4 } onChange = { this . handleChange } />
3435 < Input type = "text" label = "Disabled field" disabled />
35- < Input type = "tel" value = { this . state . withIcon } required label = "With icon" onChange = { this . handleChange . bind ( this , 'withIcon' ) } icon = "phone" />
36- < Input type = "tel" value = { this . state . withCustomIcon } label = "With custom icon" onChange = { this . handleChange . bind ( this , 'withCustomIcon' ) } icon = "favorite" />
37- < Input type = "text" value = { this . state . withHintCustomIcon } label = "With Hint Text Icon" hint = "Hint Text" onChange = { this . handleChange . bind ( this , 'withHintCustomIcon' ) } icon = "share" />
36+ < Input type = "tel" name = "withIcon" value = { this . state . withIcon } required label = "With icon" onChange = { this . handleChange } icon = "phone" />
37+ < Input type = "tel" name = "withCustomIcon" value = { this . state . withCustomIcon } label = "With custom icon" onChange = { this . handleChange } icon = "favorite" />
38+ < Input type = "text" name = "withHintCustomIcon" value = { this . state . withHintCustomIcon } label = "With Hint Text Icon" hint = "Hint Text" onChange = { this . handleChange } icon = "share" />
3839 </ section >
3940 ) ;
4041 }
0 commit comments