React component not re-rendering on state change

Posted by Ramesh Singh | Updated on

React component not re-rendering on state change. That’s because the response from chrome.runtime.sendMessage is asynchronous.

When you pause the script with the debugger, you’re giving the extension time to call the callback; by the time you continue, the data has arrived and it appears to work. To fix, you want to do the setState call after the data comes back from the Chrome extension:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers