I have component that have state as object
const [data, setData] = useState({
input,
output: '',
enableCopyToClipboard: true,
}
When listen to Observable I do following:
// reset state before loading stream
setData({
...data,
output: '',
enableCopyToClipboard: false,
});
loadingStream(request).subscribe((response) => {
resText.push(response.text);
setData({
...data,
output: resText.join(''),
});
});
Problem is my enableCopyToClipboard variable in state stays true when it should be false while streaming is ongoing. No idea why.