Explain JS threading and useState vs useRef | OpenAI