Prior Issues
Are there any existing issues or PRs that relate to this problem? If so, link them here.
What is the current behavior?
As reported by damntv on Discord, useEventListener currently does not check the event target is valid, which can cause an error if you are trying to target window, document, etc. during SSR.
Steps to Reproduce
useEventListener(window, "resize", () => {});
Throws an error when server side rendered because the window is not defined on the server.
What is the expected behavior?
@react-hookz/web should check to make sure the event target is valid, at least on server side, before trying to set the event.
Environment Details
@react-hookz/web version: 16.0.0
react version:
react-dom version:
typescript version:
- OS:
- Browser:
- Did this work in previous versions? no