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);
  }
Kj
Kj [/.] Sreekumar programs computers as a hobby and profession. Into programming from his school days, Sree uses Codemarvels to key in facts and fixes he finds interesting while working on different projects. Some of the articles here give away a few shades of his philosophical leanings too.

Leave a Comment

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