ReactJS: “this.props” is not a function when child component calls parent

前端 未结 1 368
闹比i
闹比i 2021-02-05 14:36

I have written this code and am currently wrangling with a bug in an onClick event. I have two events, the onClick event on the child element and the onChange event on the top-l

1条回答
  •  独厮守ぢ
    2021-02-05 15:20

    The problem is caused by map function, you should pass in this for thisArg when calling map:

    this.props.accounts.map(function(each_account) {
      rows.push(
        );
     }, this);
    

    However, this will cause AccountRow to have redundant variables like accounts and activeAccount. I think you should consider transfer only the onChange function:

     
    

    0 讨论(0)
提交回复
热议问题