Handle onChange in errored input in docs

old
rubenmoya 2018-01-29 20:17:46 +01:00
parent 874d9bf606
commit c6a7b5ba3a
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
class InputTest extends React.Component { class InputTest extends React.Component {
state = { name: '', phone: '', multiline: '', email: '', hint: '', label: '' }; state = { name: '', phone: '', multiline: '', email: '', hint: '', label: '', error: '' };
handleChange = (value, ev) => { handleChange = (value, ev) => {
this.setState({[ev.target.name]: value}); this.setState({[ev.target.name]: value});
@ -16,7 +16,7 @@ class InputTest extends React.Component {
<Input type='tel' label='Phone' name='phone' icon='phone' value={this.state.phone} onChange={this.handleChange} /> <Input type='tel' label='Phone' name='phone' icon='phone' value={this.state.phone} onChange={this.handleChange} />
<Input type='text' name='hint' value={this.state.hint} label='Required Field' hint='With Hint' required onChange={this.handleChange} icon='share' /> <Input type='text' name='hint' value={this.state.hint} label='Required Field' hint='With Hint' required onChange={this.handleChange} icon='share' />
{/* Just an example. Defining functions in a property, such as onClick, is a bad idea: */} {/* Just an example. Defining functions in a property, such as onClick, is a bad idea: */}
<Input type='text' label='error' error={<span>Error!! <a href="#!" onClick={e => { e.preventDefault(); console.log('some help'); }}>?</a></span>} /> <Input type='text' value={this.state.error} name="error" onChange={this.handleChange.bind(this, 'error')} label='error' error={<span>Error!! <a href="#!" onClick={e => { e.preventDefault(); console.log('some help'); }}>?</a></span>} />
</section> </section>
); );
} }