Skip to content
RED SAGSkills
medium10 pts · first answer countsreact-nativereact-hooks

Timer counter stuck at one

What does this component show after about 5 seconds?

function Timer() {
  const [count, setCount] = useState(0)
  useEffect(() => {
    const id = setInterval(() => setCount(count + 1), 1000)
    return () => clearInterval(id)
  }, [])
  return <Text>{count}</Text>
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions