How to access class variable inside Promise then() function?

 https://stackoverflow.com/questions/48064389/how-to-access-class-variable-inside-promise-then-function

If you pass a function reference, this won't point to the local class instance anymore.

You can use bind

.then(this.extractData.bind(this))

or arrow functions

.then((res) => this.extractData(res))

to get the desired behavior.

Không có nhận xét nào:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...