1234567891011121314151617181920212223242526272829 |
- import * as React from 'functional-mini/compat';
- var useInternalLayoutEffect = React.useEffect;
- var useLayoutEffect = function (callback, deps) {
- var firstMountRef = React.useRef(true);
- useInternalLayoutEffect(function () {
- return callback(firstMountRef.current);
- }, deps);
-
- useInternalLayoutEffect(function () {
- firstMountRef.current = false;
- return function () {
- firstMountRef.current = true;
- };
- }, []);
- };
- export var useComponentUpdateEffect = function (callback, deps) {
- useLayoutEffect(function (firstMount) {
- if (!firstMount) {
- return callback();
- }
- }, deps);
- };
- export default useLayoutEffect;
|