stratiformltd / react-loadable-visibility

A wrapper around react-loadable and @loadable/component to load elements once they are visible on the page.
BSD 3-Clause "New" or "Revised" License
1.01k stars 31 forks source link

window is not defined on server side #4

Closed s524797336 closed 6 years ago

s524797336 commented 6 years ago

capacities.js var IntersectionObserver = exports.IntersectionObserver = window && window.IntersectionObserver; on server side will throw error window is not defined Can you change to this? var IntersectionObserver = exports.IntersectionObserver = typeof window !== 'undefined' && window.IntersectionObserver;

tazsingh commented 6 years ago

Looks like a reasonable change to me. I’ll make this change and publish a new version when I get a chance but would also be happy to accept a pull request!

Sent from my iPhone

On Sep 22, 2017, at 9:00 AM, 刘佳闻 notifications@github.com wrote:

capacities.js var IntersectionObserver = exports.IntersectionObserver = window && window.IntersectionObserver; on server side will throw error window is not defined Can you change to this? var IntersectionObserver = exports.IntersectionObserver = typeof window !== 'undefined' && window.IntersectionObserver;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

s524797336 commented 6 years ago

Publish it to npm ASAP would be very helpful, thank you very much