Skip to content

chore: useState lazy init warnings (36) #1465

@steilerDev

Description

@steilerDev

Parent tracking issue: #1455

Summary

Resolve all 36 `@eslint-react/use-state` warnings, which flag `useState` calls where the initial value is an expensive expression that runs every render instead of just once.

Fix pattern

```tsx
// before — computes on every render
const [items, setItems] = useState(expensiveCompute());
const [map, setMap] = useState(new Map([['a', 1]]));

// after — only computes on mount
const [items, setItems] = useState(() => expensiveCompute());
const [map, setMap] = useState(() => new Map([['a', 1]]));
```

The rule fires whenever the initial value is a function call, object/array/Map/Set literal, or any non-primitive expression.

Scope

Production code (`client/src/`).

Acceptance Criteria

  • `npm run lint` reports 0 `@eslint-react/use-state` warnings
  • Initial render output unchanged
  • No new render loops

Risk

Very low. Mechanical wrap-in-arrow-fn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt cleanup work (lint, refactors, etc.)

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions