fix: crash in editor due to ResizeObserver loop limit exceeded

This commit is contained in:
thecodrr
2020-11-20 22:43:02 +05:00
parent 7882ee2957
commit ab6b3b6ba2

View File

@@ -18,12 +18,18 @@ function TitleBox(props) {
}, []);
useEffect(() => {
console.log("hello");
if (!window.ResizeObserver) return;
const myObserver = new ResizeObserver((entries) => {
const newHeight = entries[0].contentRect.height;
setHeight(newHeight > 60 ? newHeight : 60);
window.requestAnimationFrame(() => {
const newHeight = entries[0].contentRect.height;
setHeight(newHeight > 60 ? newHeight : 60);
});
});
myObserver.observe(document.querySelector(".dummyEditorTitle"));
return () => {
myObserver.disconnect();
};
}, []);
useEffect(() => {