Let’s look at how we could implement this custom Hook. We’d use the React local state to keep the current window width, and use a side effect to set that state when the window resizes:
Making Sense of React Hooks
Dan Abramov

Say I have two components rendered at the same time, and both use “width = useWindowWidth()”.

Does it mean that two event listeners will be added to the window or the state will be shared between the two components, thus having only one listener?