seatgeek / react-infinite

A browser-ready efficient scrolling container based on UITableView
Other
2.71k stars 274 forks source link

Isomorphic React : window is not defined. #144

Open pastelsky opened 8 years ago

pastelsky commented 8 years ago

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?

EugeneZ commented 8 years ago

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.

leifdalan commented 8 years ago

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.

nickretallack commented 6 years ago

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.