@workday/canvas-kit-react
Version:
The parent module that contains all Workday Canvas Kit React components
28 lines (27 loc) • 1.04 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMountLayout = exports.useMount = void 0;
const react_1 = __importDefault(require("react"));
/**
* Alias to `useEffect` with the intention to only run on mount/unmount.
* Avoids the React lint errors and encodes intent.
*/
const useMount = (callback) => {
// we only want this to be called once
// eslint-disable-next-line react-hooks/exhaustive-deps
react_1.default.useEffect(callback, []);
};
exports.useMount = useMount;
/**
* Alias to `useLayoutEffect` with the intention to only run on mount/unmount
* Avoids the React lint errors and encodes intent.
*/
const useMountLayout = (callback) => {
// we only want this to be called once
// eslint-disable-next-line react-hooks/exhaustive-deps
react_1.default.useLayoutEffect(callback, []);
};
exports.useMountLayout = useMountLayout;
;