setState inside Promise in React

后端 未结 3 1637
旧时难觅i
旧时难觅i 2021-01-12 21:47

I have a function in my React code defined like this:

getAttachment(url) {
    fetch(url).then((responseText) => {

        var response = responseText.js         


        
3条回答
  •  半阙折子戏
    2021-01-12 22:16

    try changing the getAttachment function to getAttachment = (url) => {...} and delete .bind(this)

提交回复
热议问题