Explore Library
Code QuizIntermediate

Handling Focus with useFocusEffect

Spot the bug that causes useFocusEffect to run infinitely.

Codejavascript
import { useFocusEffect } from '@react-navigation/native';

function Screen() {
  useFocusEffect(() => {
    const sub = subscribe();
    return () => sub.remove();
  });
  return <View />;
}

What is the bug in this code?