'Do variables declared outside React functional component get destroyed/deleted/garbage collected when component unmounts? Do they create memory leaks?

I want to put some variables outside the functional component because I don't want them to get re-initialized on re-render. I am wondering how they will get cleared from the memory.



Sources

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

Source: Stack Overflow

Solution Source