'While using useEffect and unsubscribe, it gives Missing return type on function warning

I'm using the following useEffect hook and in the hook, I'm setting a listener and unsubscribing to this listener inside a return.

useEffect(() => {
        const listener = firebase.auth.onAuthStateChanged(authUser => {        
        })
        return () => listener()
      }, [])

But it's giving the following warning Missing return type on function warning on this line: return () => listener()

What is the correct way of typing it without disabled something in eslint?

Any help is very welcome!



Solution 1:[1]

This should work:

Add void in your arrow function declaration after return

useEffect(() => {
    const listener = firebase.auth.onAuthStateChanged(authUser => {        
    })
    return ():void => listener()
  }, [])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ivan Lozano