Write a counter component that increments every second.
Anonymous
Use a setInterval function within the useEffect hook with an empty dependency array. Apply setState callback to make sure that the up to date value of the counter is used. Return clearInterval from the useEffect hook to ensure the interval is removed on component unmount. Use useRef to save component props between renders to avoid stale closures.
Check out your Company Bowl for anonymous work chats.