the-road-to-learn-react/use-state-with-callback

Can't get the updated value inside the call back

dbairavan opened this issue · 1 comments

setFilePath(newValue, () => {
console.log(filePath) //Here it's not priting the updated value
getTranslatedText() // In this function also I'm not getting the updated filePath value
})

I suggest:

setFilePath(newValue, () => {
  console.log(newValue) // Just use the newValue here.
  getTranslatedText(newValue) // Pass this function the new value
})