React Ajax call on load gives : “Error: Should not already be working.”

Problem : On page refreshes, the ajax calls in the componentDidMount functions throws the error : “Error: Should not already be working.”

Reason : Probably the ajax request is called before the react’s async calls framework is initialized.

Fix: Run within a timeout function
Eg –

componentDidMount() {
    setTimeout(() => {
      $.ajax(...);
    }, 400);
  }

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy This Password *

* Type Or Paste Password Here *

68,488 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>