box-ui-elements
Version:
Box UI Elements
17 lines (16 loc) • 397 B
JavaScript
import { useState } from 'react';
/**
* This hook will call the callback once in the life cycle of the component
*/
function useCallOnce(callback) {
const [hasCalled, setHasCalled] = useState(false);
return () => {
if (!hasCalled) {
setHasCalled(true);
return callback();
}
return undefined;
};
}
export default useCallOnce;
//# sourceMappingURL=useCallOnce.js.map