use-state-with-callback icon indicating copy to clipboard operation
use-state-with-callback copied to clipboard

Can't get the updated value inside the call back

Open dbairavan opened this issue 4 years ago • 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 })

dbairavan avatar Jul 26 '21 01:07 dbairavan

I suggest:

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

coryhouse avatar Oct 27 '21 21:10 coryhouse