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

96
Views
how to solve warning Use callback in setState when referencing the previous state

For this piece of code, I am getting eslint warning: warning Use callback in setState when referencing the previous state react/no-access-state-in-setstate

how can it be solved?

const sketch = await ImageManipulator.manipulateAsync(this.state.sketch, [{ rotate: 90 }], {
  base64: true,
  format: ImageManipulator.SaveFormat.PNG,
})
this.setState({ sketch: sketch.uri })

It is showing a warning for first-line(const sketch =....).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are getting warning because of this.setState({ sketch: sketch.uri }) line.

You can do something like the below code to remove the lint warning.

const sketch = await ImageManipulator.manipulateAsync(this.state.sketch, [{ rotate: 90 }], {
  base64: true,
  format: ImageManipulator.SaveFormat.PNG,
})
this.setState(() => {
  return {
    sketch: sketch.uri,
  }
})
about 4 years ago · Juan Pablo Isaza Report
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!