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);
  }
Sreekumar Kj
Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics. He now runs a conversational AI company - DheeYantra - focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.