@awsui/components-react
Version:
AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A
18 lines (17 loc) • 629 B
JavaScript
import { __spreadArrays } from "tslib";
import { useCallback, useEffect, useRef } from 'react';
export function useStableEventHandler(fn, dependencies) {
if (dependencies === void 0) { dependencies = []; }
var ref = useRef();
useEffect(function () {
ref.current = fn;
}, __spreadArrays([fn], dependencies));
return useCallback((function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.apply(undefined, args);
}), [ref]);
}