Whats going on here? I see it adds and removes a resize event listener… okay, when?What happens with the function it returns?
Why do I need to pass in an empty array? What could even go in there? What happens if I omit it (it is empty).
Where is the unmounting and mounting? What order do things happen in and when?
These have answers of course. The function runs according to the dependency array (prop, state, etc) and just on mount if empty. And the callback runs on unmount, if any. But you have to learn them. Before you do, it's magic. And when you step away, you have to re-learn it. And when it gets a bit more complicated, you're going to have to sit down and learn it better.
Why do I need to pass in an empty array? What could even go in there? What happens if I omit it (it is empty).
Where is the unmounting and mounting? What order do things happen in and when?
These have answers of course. The function runs according to the dependency array (prop, state, etc) and just on mount if empty. And the callback runs on unmount, if any. But you have to learn them. Before you do, it's magic. And when you step away, you have to re-learn it. And when it gets a bit more complicated, you're going to have to sit down and learn it better.