()
| 2 | import { View, Text, Button } from 'react-native' |
| 3 | |
| 4 | export default function App() { |
| 5 | const intervalRef = useRef() |
| 6 | const [count, setCount] = useState(0) |
| 7 | |
| 8 | useEffect(() => { |
| 9 | intervalRef.current = setInterval( |
| 10 | () => setCount((count) => count + 1), |
| 11 | 1000 |
| 12 | ) |
| 13 | |
| 14 | return () => { |
| 15 | clearInterval(intervalRef.current) |
| 16 | } |
| 17 | }, []) |
| 18 | |
| 19 | return ( |
| 20 | <View> |
| 21 | <Text style={{ fontSize: 120 }}>{count}</Text> |
| 22 | <Button |
| 23 | title="Stop" |
| 24 | onPress={() => { |
| 25 | clearInterval(intervalRef.current) |
| 26 | }} |
| 27 | /> |
| 28 | </View> |
| 29 | ) |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected