@atlaskit/motion
Version:
A set of utilities to apply motion in your application.
19 lines (18 loc) • 604 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useElementRef = void 0;
var _react = require("react");
/**
* Will return a tuple of the element and the callback ref to set.
* This is used as a work around for using `useRef` directly with Typescript
* as the types don't flow through as one would expect.
*/
var useElementRef = exports.useElementRef = function useElementRef() {
var elementRef = (0, _react.useRef)(null);
var setRef = (0, _react.useCallback)(function (ref) {
elementRef.current = ref;
}, []);
return [elementRef.current, setRef];
};