Fix hooks error. (#2000)

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
This commit is contained in:
Mitja Bezenšek 2023-10-03 14:08:59 +02:00 committed by GitHub
parent 82d10d34a5
commit 4ca4aeebe4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -676,6 +676,9 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
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<TLArrowShape> {
const maskId = (shape.id + '_clip').replace(':', '_')
// eslint-disable-next-line react-hooks/rules-of-hooks
const isEditing = useIsEditing(shape.id)
if (isEditing && labelGeometry) {
return (
<rect