mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 10:02:27 -04:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
13 lines
349 B
TypeScript
13 lines
349 B
TypeScript
import {isEqual} from 'lodash'
|
|
import {EffectCallback, useEffect, useRef} from 'react'
|
|
|
|
export const useEffectCheckEquality = (fn: EffectCallback, deps: any[]) => {
|
|
const depsRef = useRef<any[] | undefined>(undefined)
|
|
|
|
if (!depsRef.current || !isEqual(deps, depsRef.current)) {
|
|
depsRef.current = deps
|
|
}
|
|
|
|
useEffect(fn, depsRef.current)
|
|
}
|