Explore Library
Code QuizAdvanced

Counter with useEffect Bug

Spot the mistake in a React Native counter using useState and useEffect.

Codejavascript
import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';

export default function Counter() {
  const [count, setCount] = useState(0);

  useEffect(() => {
    setCount(count + 1);
  });

  return (
    <View>
      <Text>{count}</Text>
    </View>
  );
}

What is the bug in this code?