Created
March 12, 2022 15:57
-
-
Save amarbalu/5fa2d242aedf3ec7eaa6b7bdf038ec2a to your computer and use it in GitHub Desktop.
React Loadable Visibilty Package - https://github.com/stratiformltd/react-loadable-visibility/blob/master/src/react-loadable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import Loadable from 'react-loadable' | |
import createLoadableVisibilityComponent from './createLoadableVisibilityComponent' | |
import { IntersectionObserver } from './capacities' | |
function LoadableVisibility (opts) { | |
if (IntersectionObserver) { | |
return createLoadableVisibilityComponent([opts], { | |
Loadable, | |
preloadFunc: 'preload', | |
LoadingComponent: opts.loading, | |
}) | |
} else { | |
return Loadable(opts) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment