Skip to content

fix: resolve React 19 hook lint errors from eslint-config-next 16.2#14

Open
iot-rocket wants to merge 3 commits into
sbabic:mainfrom
iot-device-suite:chore/fix-react-hooks-lint
Open

fix: resolve React 19 hook lint errors from eslint-config-next 16.2#14
iot-rocket wants to merge 3 commits into
sbabic:mainfrom
iot-device-suite:chore/fix-react-hooks-lint

Conversation

@iot-rocket
Copy link
Copy Markdown

Summary

  • Resolves the 14 lint errors introduced by the react-hooks/refs, react-hooks/set-state-in-effect, and react-hooks/immutability rules that ship with eslint-config-next@16.2 (pulled in by the base branch).
  • Cleans up two actionable warnings: missing useEffect deps in use-filter-multiple-select, and an unused catch binding in auth-options.
  • Four react-hooks/incompatible-library notices remain intentionally — informational, caused by TanStack Table's useReactTable and react-hook-form's watch() returning non-memoizable references. React Compiler handles this gracefully.

Base branch is chore/update-dependencies; GitHub will auto-retarget to main once that PR merges.

Notable refactors

  • collapsible: height measurement and contentRef moved from the shared context into the Content subcomponent.
  • Deployment & Distributions DnD containers: useRef for the dragged-items state converted to useState so the DragOverlay preview re-renders correctly.
  • configuration-form & rollout SelectTargetFilterContainer: prop-to-state sync uses the documented "storing information from previous renders" pattern instead of setState-in-useEffect.
  • distribution-tag-form, target-tag-form, target-type-form: migrated from react-hook-form's one-shot defaultValues to its values prop so the form syncs automatically when the incoming default data changes.
  • total-targets-per-status-cell: delete-on-prop replaced with Object.entries(...).filter(...), matching the pattern in src/utils/columns-visibility.ts.

Bumps all minor/patch updates from npm outdated. Holds to Node 20,
ESLint 9, and TypeScript 5.8 per project constraints; skips the
corresponding majors (@types/node@25, eslint@10, typescript@6).

Adjusts the axios response-header access in the hawkbit proxy route
to satisfy the narrower header value type introduced in axios 1.15.
The React 19 hook rules shipped with eslint-config-next 16.2 flag
three categories of anti-patterns in this codebase:

- react-hooks/refs: refs read during render in Collapsible, the
  deployment DnD container, and the distribution-sets layout.
  Refactored each site to store the relevant values in state
  instead of refs so rendering observes updates correctly.

- react-hooks/set-state-in-effect: setState called synchronously
  in useEffect in configuration-form, the three tag/type forms,
  and the create-rollout select-target-filter container. Switched
  to the documented prop-to-state "store prev value in render"
  pattern for configuration-form and the rollout container, and
  migrated the tag/type forms from react-hook-form's one-shot
  defaultValues to its values prop so the form syncs automatically
  when defaultValues change.

- react-hooks/immutability: total-targets-per-status-cell deleted
  keys off a prop object; replaced with an immutable
  Object.entries().filter() transform matching the pattern used
  elsewhere in the project.
- use-filter-multiple-select: add missing useEffect deps
  (getOptionLabel, filters, setFilters, onFilterChanged) to
  satisfy react-hooks/exhaustive-deps, and drop the stale
  "Selected options changed" debug console.log.

- auth-options: switch the authorize() failure handler from
  `catch (error)` to a bare `catch` (tsconfig targets ES2022),
  removing the unused binding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant