jaredpalmer / react-fns

Browser API's turned into declarative React components and HoC's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SSR?

albinekb opened this issue Β· comments

Hi! Just found this on trending, love it 😍

I'm using next (React with SSR), I have not yet tested this lib with SSR but since most of the exposed components from here needs browser APIs to function, there's different ways you could handle that in an SSR case.

If SSR is supported I think it should be documented what the approach is (to not render on the server, sending placeholder values or something else)

and likewise, if you decide not to support SSR then that should be stated in the readme too πŸ‘

Thanks!

Fair point. Should probably check for typeof window === 'undefined' everywhere.

commented

Correct me if I am wrong, but since all the job is done in componentDidMount, which is called only on the client and not on the server, it should already work.

@prichodko this should be true, but might not be for Media. not 100% sure

commented

I tried it in Next and most of them are working. I had a problem with WindowSize (it throws Cannot read property 'toLowerCase' of undefined not sure why) and found potential bug in Network (will send PR).

Would it be nice to have SSR tests? I can work on a PR.

It is possible to make <Locales /> work on a server using headers from the request

GeoPosition can work on a server using client's IP and GeoIP DB. For sure this is out of scope for this repo

Media can work on server using device DB

commented

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

commented

Closed due to inactivity. Holler if this is a mistake, and we'll re-open it.