use-state-with-callback
use-state-with-callback copied to clipboard
Can't get the updated value inside the call back
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
})