Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
React mobx async state change issue

I'm using mobx stores in my react app for state management, I want to show an error modal for 5 seconds and then hide it, I use async in my mobx function but even though I set error variable to '', the modal keeps showing, so error variable is correctly set to error message but it's not coming back to default state "", this means delay action is not correctly being awaited?

In AppStore.js

async handleAppError(error)
    {
        const delay = (ms) => new Promise((res) => setTimeout(res, ms));
        this.setError('¡Oops, algo salió mal! Intentalo más tarde');
        await delay(5000);
        this.setError('');
    }

setError(payload)
    {
        this.error = payload;
    }

How I show and hide modal is very simple, modal never actually hides after 5 seconds...

{ root.mapStore.error != '' && (
        <ErrorModal1></ErrorModal1>
        )}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!