eslint: enable react-hooks checks

Also fix all errors, which can lead to subtile bugs.

Mostly fixings deps and refactoring to make typescript happy.
This commit is contained in:
David Lechner
2022-12-17 13:56:01 -06:00
committed by David Lechner
parent ee466ac904
commit 9d71bb4734
15 changed files with 321 additions and 269 deletions
+2 -1
View File
@@ -343,7 +343,8 @@ function useEditor(
}
return callback(maybeEditor);
}, [maybeEditor, ...deps]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [maybeEditor, callback, ...deps]);
}
/**
+7 -5
View File
@@ -81,13 +81,15 @@ const Welcome: React.VoidFunctionComponent<WelcomeProps> = ({ isVisible }) => {
return;
}
const element = elementRef.current;
// istanbul ignore if: should not happen
if (!elementRef.current) {
console.error('elementRef was null!');
if (!element) {
console.error('elementRef.current was null!');
return;
}
const two = new Two({ fitted: true }).appendTo(elementRef.current);
const two = new Two({ fitted: true }).appendTo(element);
const logo = two.load(logoSvg, (g) => {
g.center();
@@ -113,7 +115,7 @@ const Welcome: React.VoidFunctionComponent<WelcomeProps> = ({ isVisible }) => {
two.fit();
});
observer.observe(elementRef.current);
observer.observe(element);
const handleClick = (e: Event) => {
e.stopPropagation();
@@ -149,7 +151,7 @@ const Welcome: React.VoidFunctionComponent<WelcomeProps> = ({ isVisible }) => {
two.renderer.domElement.removeEventListener('pointerdown', handleClick);
observer.disconnect();
two.removeEventListener('update');
elementRef.current?.removeChild(two.renderer.domElement);
element.removeChild(two.renderer.domElement);
two.clear();
};
}, [isVisible]);