From 4ca4aeebe4c10b514a6995476d15bf08a8289534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitja=20Bezen=C5=A1ek?= Date: Tue, 3 Oct 2023 14:08:59 +0200 Subject: [PATCH] Fix hooks error. (#2000) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were conditionally using hooks, which caused the minified error when running the prod build of React. We now use hooks before the early returns. Fixes [#2001](https://github.com/tldraw/tldraw/issues/2001) ### Change Type - [x] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [ ] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [ ] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version --- packages/tldraw/src/lib/shapes/arrow/ArrowShapeUtil.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tldraw/src/lib/shapes/arrow/ArrowShapeUtil.tsx b/packages/tldraw/src/lib/shapes/arrow/ArrowShapeUtil.tsx index 2f3dc7215..a7587311b 100644 --- a/packages/tldraw/src/lib/shapes/arrow/ArrowShapeUtil.tsx +++ b/packages/tldraw/src/lib/shapes/arrow/ArrowShapeUtil.tsx @@ -676,6 +676,9 @@ export class ArrowShapeUtil extends ShapeUtil { const labelGeometry = shape.props.text.trim() ? (geometry.children[1] as Rectangle2d) : null + // eslint-disable-next-line react-hooks/rules-of-hooks + const isEditing = useIsEditing(shape.id) + if (!info) return null if (Vec2d.Equals(start, end)) return null @@ -693,9 +696,6 @@ export class ArrowShapeUtil extends ShapeUtil { const maskId = (shape.id + '_clip').replace(':', '_') - // eslint-disable-next-line react-hooks/rules-of-hooks - const isEditing = useIsEditing(shape.id) - if (isEditing && labelGeometry) { return (