React is rendered twice in the component render (). The first rendering is successful, and the second return function is undefine.

when I was writing a login page.
< LoginForm icon="mobile" onChange= {() = > this.handleChange ()} / >

written in the parent component

use < input className="number-input" type= {filetype} onChange= {this.props.onChange} value= {this.state.value} / >
in the child component to get the value of the input box, and then write constuctor () {super (); this.state= {value:""}}

in the parent component.

but the console mistakenly says that value is empty, and then I set the value of the subcomponent to empty, give state.value a value in the controller, and I can print the value of state.value. Then I print the function this.props.onChange on return under render () {} in the subcomponent, and print it twice in the browser. Once it returns the undefine, returned by the function function,. Excuse me, what is the problem and how to solve it.

Mar.07,2021

  • parent component:
  

there is nothing wrong with this! Can print it out,

Menu