Consider the React code declared inside LoremComponent.tsx below:
const foo = "bar";
export default (props) => {
return (
<h1>{foo}</h1>
)
}
What is the lifetime of variable foo -
- If the LoremComponent.tsx is not imported anywhere, then this variable wont be declared inside memory?
- If the component is imported in other component, then what will be the lifetime of the variable foo?
- Or till the React application is running?