fix: Cannot import from app in shared

This commit is contained in:
Tom Moor
2022-03-30 18:21:35 -07:00
parent 6c25f8fc72
commit c5b9a742c0
2 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
import { useState, useEffect } from "react";
export default function useComponentSize(
ref: React.RefObject<HTMLElement>
): { width: number; height: number } {
const [size, setSize] = useState({
width: ref.current?.clientWidth || 0,
height: ref.current?.clientHeight || 0,
});
useEffect(() => {
const sizeObserver = new ResizeObserver((entries) => {
entries.forEach(({ target }) => {
if (
size.width !== target.clientWidth ||
size.height !== target.clientHeight
) {
setSize({ width: target.clientWidth, height: target.clientHeight });
}
});
});
if (ref.current) {
sizeObserver.observe(ref.current);
}
return () => sizeObserver.disconnect();
}, [ref]);
return size;
}

View File

@@ -1,6 +1,6 @@
import * as React from "react";
import useComponentSize from "~/hooks/useComponentSize";
import Frame from "../components/Frame";
import useComponentSize from "../components/useComponentSize";
import { EmbedProps as Props } from ".";
const URL_REGEX = /^https:\/\/(www\.)?berrycast.com\/conversations\/(.*)$/;