Closed kylehalleman closed 8 years ago
Thanks @kylehalleman! To be honest I have done little testing with pressure in npm, I will do some testing with that and try to come up with a fix!
@kylehalleman just pushed v1.0.1 that should fix this. Let me know if it works for you https://github.com/yamartino/pressure/releases/tag/v1.0.1
Just tested, server rendering works with no errors being thrown, thanks!
Currently, the code supplies
false
if no window or document are found when initiating. However, the code still runs with window and document set to false, causing errors when trying to call methods onfalse
that do not exist (e.g. "Cannot use 'in' operator to search for 'ontouchstart' in false").This occurs when used in a React app where the initial render is server side, since even if Pressure isn't set until
componentDidMount
, the import of Pressure triggers initialization, throwing errors. I'd suggest either returning early if there is no window or document, or else make Pressure be explicitly initialized (such asvar pressure = Pressure();
), at least in an NPM environment.