Remove unused destructured variable and document the convention
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -154,8 +154,8 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps)
|
|||||||
|
|
||||||
const [updateCategory, isUpdating]
|
const [updateCategory, isUpdating]
|
||||||
= useMutation<CategorySectionUpdateMutation>(updateCategoryMutation);
|
= useMutation<CategorySectionUpdateMutation>(updateCategoryMutation);
|
||||||
const [moveCookie, _isMoving]
|
const [moveCookie] =
|
||||||
= useMutation<CategorySectionMoveCookieMutation>(moveCookieMutation);
|
useMutation<CategorySectionMoveCookieMutation>(moveCookieMutation);
|
||||||
|
|
||||||
const [isEditingCategory, setIsEditingCategory] = useState(false);
|
const [isEditingCategory, setIsEditingCategory] = useState(false);
|
||||||
const [editingCookieIndex, setEditingCookieIndex] = useState<number | null>(null);
|
const [editingCookieIndex, setEditingCookieIndex] = useState<number | null>(null);
|
||||||
|
|||||||
@@ -11,6 +11,24 @@ This document describes **how to define and shape** React components in Probo fr
|
|||||||
| `@probo/ui`, Tailwind, `tailwind-variants`, folders, skeletons, compound modules | [`contrib/claude/ui.md`](ui.md) |
|
| `@probo/ui`, Tailwind, `tailwind-variants`, folders, skeletons, compound modules | [`contrib/claude/ui.md`](ui.md) |
|
||||||
| Relay queries, fragments, loaders, `queryRef` | [`contrib/claude/relay.md`](relay.md) |
|
| Relay queries, fragments, loaders, `queryRef` | [`contrib/claude/relay.md`](relay.md) |
|
||||||
|
|
||||||
|
## Destructuring
|
||||||
|
|
||||||
|
**Never destructure a value you do not use.** If only one element of a tuple or object is needed, stop destructuring at that element or omit the unused keys. Do not assign to `_`-prefixed throwaway names.
|
||||||
|
|
||||||
|
### Do / don't: unused destructured values
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// Bad — _isMoving is never read
|
||||||
|
const [moveCookie, _isMoving] =
|
||||||
|
useMutation<MoveCookieMutation>(moveCookieMutation);
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// Good — stop at the last element you need
|
||||||
|
const [moveCookie] =
|
||||||
|
useMutation<MoveCookieMutation>(moveCookieMutation);
|
||||||
|
```
|
||||||
|
|
||||||
## Component shape
|
## Component shape
|
||||||
|
|
||||||
| Rule | Convention |
|
| Rule | Convention |
|
||||||
|
|||||||
Reference in New Issue
Block a user