I am getting a response from django server and I need after that to set clock variable to true, because than I use that variable in a component.
let clock = false;
useEffect(() => {
switch (true) {
........
case dataParsed.type === "ClockInfo":
{
clock = true;
}
break;
}
};
}, []);
<Header word={catchword} socketRef={socketRef} clock={clock} />
The clock value doesn't change correctly, it always shows false. I know that is cause it brings back to the false value every time react renders components, so how can I do it correctly?
I tried to use useRef, but it doesn't help at all. In my component I have a condition which start to work when clock == true.