Object update in useState is not working as expected
Unanswered
XotEmBotZ posted this in #help-forum
Javascript Scares
Even after the change in label the insertion dosent take place in right place.
1st label-Control
2nd label-Fedora Laptop
But the fedora laptop length is 0
the console.log statement result
What am I doing wrong??
const stopDetect = () => {
const d = false
console.log("In toggel", d)
if (d) cameraObj.start()
if (!d) cameraObj.stop()
setDetectStart(d)
notifications.show({
message: `Data regarding ${label} is captured`,
withCloseButton: true,
title: "Data captured",
color: "green",
})
results[label] = tempData
console.log(label, results, results[label])
setResults(results)
setTempData([])
setLabel("")
}Even after the change in label the insertion dosent take place in right place.
1st label-Control
2nd label-Fedora Laptop
But the fedora laptop length is 0
the console.log statement result
Fedora Laptop {control: Array(257), Fedora Laptop: Array(0)} []What am I doing wrong??