Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR support #377

Open
Saeeed-B opened this issue Feb 22, 2022 · 2 comments
Open

SSR support #377

Saeeed-B opened this issue Feb 22, 2022 · 2 comments

Comments

@Saeeed-B
Copy link

@ameerthehacker
This package does not appear to support ssr.
Photos are not displayed in the viewport.

@ameerthehacker
Copy link
Collaborator

No more features are actively developed but I'm happy to accept a PR if you wish to contribute

@prmichaelsen
Copy link
Contributor

prmichaelsen commented Jul 24, 2022

@Saeeed-B

  /**
   * https://github.com/alex-cory/use-ssr
   * https://github.com/alex-cory/use-ssr/blob/master/useSSR.ts
   */
  const isBrowser: boolean = !!(
    typeof window !== 'undefined' &&
    window.document &&
    window.document.createElement
  );
  
  const Lazy = ({ children }) => {
    if (lazy && isBrowser) {
      return (
        <LazyLoad
          className={classes.avatar}
          once
          placeholder={<LoadingSpinner />}
        >
          {{children}}
        </LazyLoad>
      );
    } else {
      return children;
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants