mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
14 lines
372 B
JavaScript
14 lines
372 B
JavaScript
|
import { useEffect, useRef } from 'react'
|
||
|
import _ from 'lodash'
|
||
|
|
||
|
export default function useDeepCompareEffect(callback, dependencies) {
|
||
|
const ref = useRef()
|
||
|
return useEffect(() => {
|
||
|
if (_.isEqual(dependencies, ref.current)) {
|
||
|
return
|
||
|
}
|
||
|
ref.current = dependencies
|
||
|
callback()
|
||
|
}, dependencies) // eslint-disable-line react-hooks/exhaustive-deps
|
||
|
}
|