react.js call parent function from child

前端 未结 3 2081
小蘑菇
小蘑菇 2021-01-12 02:16

I know there are a few similar questions here and here but I am having a tough time understanding what is the correct thinking today on this and extrapolating it to my situa

3条回答
  •  迷失自我
    2021-01-12 02:21

    You need to pass handleScoreRemove through props

    var scoreNodes = this.props.data.map(function(score) {
      return 
      
    }, this);
    

    and in Score component call it like this

    removeRecord: function(e) {
       this.props.handleScoreRemove( /* add arguments what do you need */ );
    },
    

提交回复
热议问题