@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
22 lines (21 loc) • 556 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useConstructor;
var _react = require("react");
/**
*
* Hook to run code once in a functional component.
* Emulates the behaviour of a `constructor` in a class component
* Place this at the top of your functional component so that it is run first.
*
* @param callback Callback function to run once
*/
function useConstructor(callback) {
var hasRun = (0, _react.useRef)(false);
if (!hasRun.current) {
callback();
hasRun.current = true;
}
}