how to call internal function after chrome.storage.sync.get callback in chrome extension+reactjs?

Viewed 665

I have chrome extension with reactjs.

My component has some internal functions and I called them after callback of chrome.storage.sync.get.

But I got "XXX is not function" error.

Here is my code snippet.

class App extends React.Component {
  func1(){}
  func2() {
    chrome.storage.sync.get(null, function(data) {
      this.func1();
      this.setState(...);
    })
  }

}

I can't call func1.

1 Answers
Related