const formControls = controls.slice();
console.log(controls == formcontrols)
const formControls = controls.slice();
changeHandler = (value, controlName, controls) => {
const formControls = controls.slice();
const control = formControls[controlName]
control.touched = true
control.value = value
control.valid = validate(control.value, control.validation)
formControls[controlName] = control
this.setState({
formcontrols,
isFormValid: validateForm()
})
}
renderControls(controls) {
return controls.map((control,index) => {
return(
<Auxillary key={index}>
<Input
type={control.type}
label={control.label}
value={control.value}
valid={control.valid}
shouldValidate={!!control.validation}
touched={control.touched}
errorMessage={control.errorMessage}
onChange={event => this.changeHandler(event.target.value, index, controls)}
/>
</Auxillary>
)
})
}
Это вызываю в render-e
{this.renderControls(this.state.enrollerControls)}
this.setState({
formcontrols,
isFormValid: validateForm()
})
<div class="result-box__video-info " >
<div class="result-box__author">
<img src="src/views/images/result-box/user-icon.png" class="img-responsive" alt="user">
<span class="result-box__text_hover result-box__text_bold">${data.channelTitle[i]}</span>
</div>
<div class="result-box__date">
<img src="src/views/images/result-box/Без имени-1.png"class="img-responsive" alt="calendar">
<span class="result-box__text_hover result-box__text_bold">${data.clipDate[i]}</span>
</div>
<div class="result-box__video-info video-info" >
<div class="video-info__author">
<img src="src/views/images/result-box/user-icon.png" class="img-responsive" alt="user">
<span class="video-info__text video-info__text_hover result-box__text_bold">${data.channelTitle[i]}</span>
</div>
<div class="video-info__date">
<img src="src/views/images/result-box/Без имени-1.png"class="img-responsive" alt="calendar">
<span class="video-info__text video-info__text_hover video-info__text_bold">${data.clipDate[i]}</span>
</div>