rendering multiple attributes to component react code example
Example 1: react set multible attribute values
render () {
return <div className='form-field'>
<label className='form-label' htmlFor='user-email'>Email: </label>
<input className='form-input form-input--email' id='user-email' type='email' name='user-email' placeholder={this.props.placeholder} required>
</div>
}
Example 2: react set multible attribute values
render () {
const attributes = {
className: 'form-input form-input--email',
id: 'user-email',
type: 'email',
name: 'user-email',
placeholder: this.props.placeholder,
required: this.state.required
}
return <div className='form-field'>
<label className='form-label' htmlFor='user-email'>Email: </label>
<input {...attributes}>
</div>
}