Skip to content

fix(react-sdk): respect initialLoading during initialization#668

Merged
roncohen merged 2 commits into
mainfrom
fix/react-sdk-bootstrap-initial-loading
Jul 17, 2026
Merged

fix(react-sdk): respect initialLoading during initialization#668
roncohen merged 2 commits into
mainfrom
fix/react-sdk-bootstrap-initial-loading

Conversation

@roncohen

Copy link
Copy Markdown
Contributor

Problem

ReflagClientProvider uses initialLoading for its first render, but its stateUpdated listener ignores the prop and sets loading to true as soon as the client emits "initializing".

For ReflagBootstrappedProvider, which defaults initialLoading to false, this causes the provider to briefly:

  • replace children with loadingComponent
  • report true from useIsLoading()

This is the adjacent loading-state issue called out as out of scope in #667.

Fix

Track whether the client has completed its first initialization. During the initial "initializing" lifecycle, continue respecting initialLoading. Once initialization has completed, preserve the existing behavior where later setContext() refreshes report loading.

This leaves the browser client's lifecycle state and public stateUpdated event sequence unchanged.

Test

Add a regression test that holds a bootstrapped client in "initializing" and verifies that:

  • the loading component is never rendered
  • bootstrapped children remain mounted
  • useIsLoading() remains false

Also keep coverage that subsequent context refreshes still report loading.

Verified with:

  • yarn workspace @reflag/react-sdk test usage.test.tsx --run
  • yarn oxfmt --check packages/react-sdk/src/index.tsx packages/react-sdk/test/usage.test.tsx
  • yarn oxlint packages/react-sdk/src/index.tsx packages/react-sdk/test/usage.test.tsx
  • yarn exec tsc --project packages/react-sdk/tsconfig.build.json --noEmit

@roncohen
roncohen added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit a95972c Jul 17, 2026
7 checks passed
@roncohen
roncohen deleted the fix/react-sdk-bootstrap-initial-loading branch July 17, 2026 13:33
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