Skip to content

Fix stale closures in useCallback with empty dependency arrays #83

@tmshv

Description

@tmshv

Problem

Several components use useCallback with empty or incomplete dependency arrays, causing stale closures where the callback captures outdated state/props.

Affected files

  1. src/components/LayersOutline/index.tsx:55, 86moveLayerItem and renderLayerItem callbacks have empty [] dependency arrays but use values that can change
  2. src/components/SourcesOutline/index.tsx:28-57 — same pattern
  3. src/components/LeftSidebar/LayersTab.tsx:29onClick callback with empty dependency array

What needs to change

Add the correct dependencies to each useCallback array. Consider enabling the react-hooks/exhaustive-deps ESLint rule (see related issue) to catch these automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions