Nesting Functions in JS

后端 未结 4 819
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 02:58

I am trying to understand some concepts in reactjs, but I\'m unable to understand nesting of functions. I created the below example for investigating my concern.

In

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 03:55

    The context changes inside the map function, therefore "this" points to something else. If you want to have the "proper" this you could use an arrow function, which has lexical "this".

    const displaydata = data.map(point => {
      return (
        
    {this.renderInnerContent()}
    ) });

提交回复
热议问题