Skip to content

bug(data): useFileWatch keeps stale event state when path changes #3762

Description

@Tomeshwari-02

Summary

useFileWatch in packages/data/src/hooks/useFileWatch.ts creates a new watcher when path or options change, but it does not reset data, error, or loading for the new target.

Reproduction

  1. Watch path A and trigger a change so data is populated.
  2. Re-render the hook with path B.
  3. Inspect the hook state before path B emits any event.

Expected behavior

A new watched path should start with data: null, error: null, and loading: true until the new watcher receives an event or fails.

Actual behavior

The last event from path A remains visible while the hook is already watching path B, which can make file monitors report changes for the wrong target.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

assignedIssue claimed by a contributor.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions