passing data from child to parent component - react - via callback function

后端 未结 6 1374
花落未央
花落未央 2020-12-06 07:40

passing data from child to parent component via callback function but somehow it\'s not working. what am I doing wrong here? passing data from child to parent component - re

6条回答
  •  臣服心动
    2020-12-06 08:08

    Two things that you need to correct it:

    1. if you want to access new state, you don't use this.state.input after this.setState({input: 'xxx'}). Here is reason why not it.
    2. this.passingProps = this.passingProps.bind(this) is defined what this is current scope. when you use this in component's function, this need to be bind.

    Changed codepen

提交回复
热议问题