A
A
Artyom2020-05-23 11:52:15
React
Artyom, 2020-05-23 11:52:15

Why does state change on its own even though I'm not assigning anything?

In this code, this.setState is simply written and I do not assign anything inside, however, the state changes. What's happening?

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({       
    })
  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question