Skip to content

fix: sync useLatestRef during render to prevent stale visitor/flags r… - #142

Merged
Heihokon merged 4 commits into
masterfrom
fix-stale-data
Jul 2, 2026
Merged

fix: sync useLatestRef during render to prevent stale visitor/flags r…#142
Heihokon merged 4 commits into
masterfrom
fix-stale-data

Conversation

@Heihokon

@Heihokon Heihokon commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

…eads

useLatestRef updated ref.current inside a useEffect, which runs after the render commits. Consumers of useFlagship (getFlags, getFlag, fetchFlags, ...) read these refs synchronously, so on the render where the visitor first becomes ready, they could still see the previous (visitor-less) render's data even though flagsStatus already reported FETCHED. Writing ref.current during render removes that one-commit lag.

Heihokon added 4 commits July 1, 2026 15:00
…eads

useLatestRef updated ref.current inside a useEffect, which runs after
the render commits. Consumers of useFlagship (getFlags, getFlag,
fetchFlags, ...) read these refs synchronously, so on the render where
the visitor first becomes ready, they could still see the previous
(visitor-less) render's data even though flagsStatus already reported
FETCHED. Writing ref.current during render removes that one-commit lag.
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@Heihokon
Heihokon merged commit 3a74aec into master Jul 2, 2026
3 checks passed
@Heihokon
Heihokon deleted the fix-stale-data branch July 2, 2026 15:10
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