Skip to content

Instantly share code, notes, and snippets.

@oney
Created June 3, 2022 08:56
Show Gist options
  • Save oney/a7c9b6c5f953e97faabbe3f6437b8e4d to your computer and use it in GitHub Desktop.
Save oney/a7c9b6c5f953e97faabbe3f6437b8e4d to your computer and use it in GitHub Desktop.
function Note() {
const [text, setText] = useState('');
const onTick = useEvent(() => {
count += 1; // 😩 I can't modify 'count'
saveDraft(text, count);
});
useEffect(() => {
let count = 0;
const id = setInterval(onTick, 1000);
return () => clearInterval(id);
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment