mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
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:
committed by
David Lechner
parent
ee466ac904
commit
9d71bb4734
@@ -343,7 +343,8 @@ function useEditor(
|
||||
}
|
||||
|
||||
return callback(maybeEditor);
|
||||
}, [maybeEditor, ...deps]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [maybeEditor, callback, ...deps]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user