mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
* Replace useComponentSize with react-use-measure - Add react-use-measure dependency - Replace all useComponentSize usages with useMeasure hook - Remove useComponentSize hook file - Update imports across all affected components: - app/components/Header.tsx - app/components/ResizingHeightContainer.tsx - app/scenes/Document/components/Header.tsx - app/scenes/Document/components/MeasuredContainer.tsx - shared/editor/embeds/Berrycast.tsx Fixes #9812 * Remove unused breadcrumbsRef The breadcrumbsRef is no longer needed since we're using breadcrumbsMeasureRef directly for measuring the breadcrumbs element. --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
29 lines
541 B
TypeScript
29 lines
541 B
TypeScript
import * as React from "react";
|
|
import useMeasure from "react-use-measure";
|
|
|
|
export const MeasuredContainer = <T extends React.ElementType>({
|
|
as: As,
|
|
name,
|
|
children,
|
|
...rest
|
|
}: {
|
|
as: T;
|
|
name: string;
|
|
children?: React.ReactNode;
|
|
} & React.ComponentProps<T>) => {
|
|
const [measureRef, rect] = useMeasure();
|
|
|
|
return (
|
|
<As
|
|
{...rest}
|
|
ref={measureRef}
|
|
style={{
|
|
[`--${name}-width`]: `${rect.width}px`,
|
|
[`--${name}-height`]: `${rect.height}px`,
|
|
}}
|
|
>
|
|
{children}
|
|
</As>
|
|
);
|
|
};
|