Skip to content

Conversation

@gihan9a
Copy link
Contributor

@gihan9a gihan9a commented Oct 3, 2018

This PR enables the image component to be executed on server side for SSR. Otherwise it throws following error.

ReferenceError: window is not defined at new r (<path>/node_modules/react-lazy-load-image-component/build/index.js:1:7434) ... 

Additionally we can use it with visibleByDefault option visibleByDefault={typeof window === "undefined"} to output image src tags from server rendered content.

@Aljullu Aljullu merged commit 814b3a5 into Aljullu:master Oct 7, 2018
@Aljullu
Copy link
Owner

Aljullu commented Oct 7, 2018

This looks good, thanks for working on this! 🎉

@Aljullu Aljullu self-requested a review October 7, 2018 11:31
@gihan9a
Copy link
Contributor Author

gihan9a commented Oct 7, 2018

Thank you for merging 👍

@petertenhoor
Copy link

Thanks for this issue. It solved my problem. Had to do the following to make my component work with server side rendering:

<LazyLoadImage className={styles.footerImage} effect="opacity" visibleByDefault={typeof window === "undefined"} src={require("../../images/super-cool-image.png")} alt="Super cool alt tag"/> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants