react-native-gifted-chat-flashlist
Version:
React Native Gifted Chat with FlashList optimization for better performance
17 lines • 650 B
JavaScript
import { useLayoutEffect, useRef } from 'react';
/**
* A custom useEffect hook that only triggers on updates, not on initial mount
* Idea stolen from: https://stackoverflow.com/a/55075818/1526448
* @param {()=>void} effect the function to call
* @param {DependencyList} dependencies the state(s) that fires the update
*/
export function useUpdateLayoutEffect(effect, dependencies = []) {
const isInitialMount = useRef(true);
useLayoutEffect(() => {
if (isInitialMount.current)
isInitialMount.current = false;
else
effect();
}, dependencies);
}
//# sourceMappingURL=useUpdateLayoutEffect.js.map