2017-07-21 61 views

回答

0

您需要在回調中保留應用的上下文。

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

請注意,我改變了你的回調一個arrow function,不結合自己的this價值,而是採用了相同的情況下,因爲它是從調用的函數 - 在這種情況下,你的應用程序。

+0

非常感謝。你很優秀。 –

相關問題