React Child Component Not Updating After Parent State Change

前端 未结 2 1183
忘掉有多难
忘掉有多难 2020-12-04 07:41

I\'m attempting to make a nice ApiWrapper component to populate data in various child components. From everything I\'ve read, this should work: https://jsfiddle.net/vinnieja

2条回答
  •  感动是毒
    2020-12-04 08:13

    There are some things you need to change.

    When fetch get the response, it is not a json. I was looking for how can I get this json and I discovered this link.

    By the other side, you need to think that constructor function is called only once.

    So, you need to change the way that you retrieve the data in component.

    Here, I left an example code: https://jsfiddle.net/emq1ztqj/

    I hope that helps.

提交回复
热议问题