@atlaskit/popup
Version:
A popup displays brief content in an overlay.
19 lines (18 loc) • 766 B
JavaScript
import React, { Fragment, useLayoutEffect, useRef } from 'react';
// eslint-disable-next-line @repo/internal/react/require-jsdoc
export var RepositionOnUpdate = function RepositionOnUpdate(_ref) {
var children = _ref.children,
update = _ref.update;
// Ref used here to skip update on first render (when refs haven't been set)
var isFirstRenderRef = useRef(true);
useLayoutEffect(function () {
if (isFirstRenderRef.current) {
isFirstRenderRef.current = false;
return;
}
// callback function from popper that repositions pop-up on content Update
update();
}, [update]);
// wrapping in fragment to make TS happy (known issue with FC returning children)
return /*#__PURE__*/React.createElement(Fragment, null, children);
};