material-ui-popup-state
Version:
easiest way to create menus, popovers, and poppers with material-ui
18 lines • 647 B
JavaScript
import * as React from 'react';
export function useEvent(handler) {
// istanbul ignore next
if (typeof window === 'undefined') {
// useLayoutEffect doesn't work on the server side, don't bother
// trying to make callback functions stable
return handler;
}
const handlerRef = React.useRef(null);
React.useLayoutEffect(() => {
handlerRef.current = handler;
});
return React.useCallback((...args) => {
var _handlerRef$current;
(_handlerRef$current = handlerRef.current) === null || _handlerRef$current === void 0 || _handlerRef$current.call(handlerRef, ...args);
}, []);
}
//# sourceMappingURL=useEvent.mjs.map