title: Is React Native's Keyboard's removeListener function required?
body: <p>The example code for React Native's keyboard has <code>addListener</code> and <code>removeListener</code> functions:</p>
  <pre><code>  useEffect(() =&gt; {
      Keyboard.addListener(&quot;keyboardDidShow&quot;, _keyboardDidShow);
      Keyboard.addListener(&quot;keyboardDidHide&quot;, _keyboardDidHide);
  
      return () =&gt; {
        Keyboard.removeListener(&quot;keyboardDidShow&quot;, _keyboardDidShow);
        Keyboard.removeListener(&quot;keyboardDidHide&quot;, _keyboardDidHide);
      };
    }, []);
  
    const _keyboardDidShow = () =&gt; {
      alert(&quot;Keyboard Shown&quot;);
    };
  
    const _keyboardDidHide = () =&gt; {
      alert(&quot;Keyboard Hidden&quot;);
    };
  </code></pre>
  <p>Is this code equivalent or will there be a memory leak from not cleaning up the listener?</p>
  <pre><code>  useEffect(() =&gt; {
      Keyboard.addListener(&quot;keyboardDidShow&quot;, () =&gt; alert(&quot;Keyboard Shown&quot;);
      Keyboard.addListener(&quot;keyboardDidHide&quot;, () =&gt; alert(&quot;Keyboard Hidden&quot;);
    }, []);
  </code></pre>