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 { useReducer } from 'react'; | |
import debounce from 'lodash/debounce'; | |
function windowSizeReducer(state, action) { | |
if (action.type === 'resize') { | |
return action.width; | |
} | |
return state; | |
} |
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 'intersection-observer'; | |
import { useCallback, useState, useEffect, useRef } from 'react'; | |
const defaultEntry = { | |
isIntersecting: false, | |
intersectionRatio: 0 | |
}; | |
const defaultOptions = {}; | |
function useElementVisibility(options = defaultOptions) { |
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, { useEffect, useRef } from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
// Custom hook | |
function useLazyImageObserver(target) { | |
useEffect(() => { | |
if (!target.current) { | |
return; |