react-infinite icon indicating copy to clipboard operation
react-infinite copied to clipboard

Isomorphic React : window is not defined.

Open pastelsky opened this issue 9 years ago • 3 comments

When I try to use this library in an isomorphic app, i get

[ReferenceError: window is not defined]

  ReferenceError: window is not defined
      at [object Object].generateComputedProps (server.js:3074:68)
      at [object Object].recomputeInternalStateFromProps (server.js:3185:31)
      at [object Object].getInitialState (server.js:3051:35)

How do i proceed?

pastelsky avatar Mar 08 '16 10:03 pastelsky

react-infinite does not use window internally. Assuming you are having this issue because you need to use window to provide the scrollTop and scrollLeft properties, simply check for window before using it and pass a value like 0 or whatever makes sense for your application.

EugeneZ avatar May 31 '16 19:05 EugeneZ

It appears you do, when trying to set container height with useWindowAsScrollContainer prop https://github.com/seatgeek/react-infinite/blob/master/src/react-infinite.jsx#L128

Also having this issue.

leifdalan avatar Aug 12 '16 15:08 leifdalan

It's no longer throwing an error on server-side rendering, but it is setting height:NaN when I attempt to render a page with useWindowAsScrollContainer on the server side. The problem doesn't go away until I scroll up and down a bit.

nickretallack avatar Mar 27 '18 05:03 nickretallack