airbnb / hypernova

A service for server-side rendering your JavaScript views
MIT License
5.82k stars 208 forks source link

window, document in component #80

Closed olpoco closed 7 years ago

olpoco commented 7 years ago

What's the best way to server side render component that checks uses window and document which are only available in the browser?

goatslacker commented 7 years ago

You can use typeof window === 'undefined' or typeof document === 'undefined' to check for their existence if that's what you're asking.

Otherwise, make sure that you're using these only on componentDidMount and never at eval-time.