gyorgygutai / react-sticky-fill

Dead simple Stickyfill ReactJS wrapper
MIT License
12 stars 7 forks source link

Support server side rendering #6

Open sebas5384 opened 6 years ago

sebas5384 commented 6 years ago

ReferenceError: window is not defined
    at Function.shim (/Users/me/Projects/my-project/webapp/node_modules/css-supports/index.js:48:18)
    at Object.<anonymous> (/Users/me/Projects/my-project/webapp/node_modules/react-sticky-fill/lib/components/ReactStickyfill.js:35:26)```
MartinezEst commented 6 years ago

Would want same

lordoffreaks commented 6 years ago

+1

gyorgygutai commented 5 years ago

Hey guys. I have no experience with server side rendering. Care to send a PR for this?

nickensoul commented 5 years ago

@gyorgygutai the main thing is that window is undefined at server env. This way, for example, you want to be sure, is type of window not undefined.

natterstefan commented 5 years ago

I'd need that bugfix/feature as well. But I guess it's not only react-sticky-fill's issue, but also from stickyfill: https://github.com/wilddeer/stickyfill/issues/99.

I have two suggestions:

  1. Can you remove supports.shim(), for instance? It is not recommended by the css-supports library creator: https://www.npmjs.com/package/css-supports#without-shimming-recommended.
  2. And can't the _getPositionStyleValue() check only happen on the client and not on the server? Because I assume, that this will cause issues as well, once 1. is resolved/done.

PS: I did not had the time to create a PR, because at the end we decided to remove react-sticky-fill from the app. So I put it up here for the record. So if anyone else has the time to try it - feel free to to it. :)

ViktorMeduneckij commented 4 years ago

+1