scaleflex / react-cloudimage-responsive

Cloudimage Responsive will smartly resize, compress and accelerate images across the World in your site for all devices. The plugin supports lazy loading technique with fancy animation on image load. Any questions or issues, please report to https://github.com/scaleflex/react-cloudimage-responsive/issues
MIT License
45 stars 16 forks source link

Not SSR friendly #6

Closed theoinglis closed 5 years ago

theoinglis commented 5 years ago

I have had to workaround this for now, but I would recommend looking at the user agent and allowing that to make a good prediction of max widths that can be updated when the image is rendered in the frontend

dzmitry-stramavus commented 5 years ago

hey @theoinglis ,

would you like to describe" looking at the user agent and allowing that to make a good prediction of max widths " how do you see this?

theoinglis commented 5 years ago

Hi @dzmitry-stramavus, thanks for following up.

I use a package called mobile-detect to predict the device size and then use that to define max widths the image is likely to be. However, adding this would mean that you would need a user to pass in the user agent which I don't think you would want to do. As an optional parameter it might be useful though?

Anyway, I think the key task to achieve is simply making it SSR friendly by removing references to window, etc.

dwafotapa commented 5 years ago

Backing up @theoinglis 's request here.

Using Next.js and server-side rendering, I've had to add this module https://github.com/martpie/next-transpile-modules as your library is not transpiled to es5 and imports were failing when building my project. Also, I've had to create wrappers around CloudimageProvider, Img, BackgroundImg to render them on clients only.

Could you work on a more SSR-friendly version please?

dzmitry-stramavus commented 5 years ago

yep, I will work on it in the next release

theoinglis commented 5 years ago

Hi @dzmitry-stramavus. Has there been any progress on this?

dzmitry-stramavus commented 5 years ago

@theoinglis , hey, our team was on vacation. We will try to find time during the week on it.

rwproj commented 5 years ago

hey, how is it going with making library SSR friendly? wanted to use it in our project but the SSR incompatibility makes us sad :(

dzmitry-stramavus commented 5 years ago

done in 1.6.5 version