React read value of button clicked

前端 未结 4 2021
谎友^
谎友^ 2020-12-31 17:20

Sorry if this topic it\'s probably a copy of another one, but i don\'t understand what i\'m doing wrong with my code + i\'m really new to react. I tried several solutions bu

4条回答
  •  时光说笑
    2020-12-31 17:53

    • In handleInput function you were passing the "props" but using using "this.props"
    • onClick should be there for every button
    • Should not pass the string 'value' rather do this "onClick={(e) => this.handleInput(e)}"
    • you can access with event.target.value

提交回复
热议问题