Skip to content

chore: adding deprecated flag hooks#1166

Merged
joker23 merged 4 commits intomainfrom
skz/sdk-1993/deprecated-hooks
Mar 13, 2026
Merged

chore: adding deprecated flag hooks#1166
joker23 merged 4 commits intomainfrom
skz/sdk-1993/deprecated-hooks

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Mar 10, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

sdk-1993


Note

Medium Risk
Introduces a new exported hook with Proxy-based evaluation behavior that can affect runtime performance and event emission semantics for consumers; changes are covered by targeted unit tests and are otherwise additive.

Overview
Adds a deprecated useFlags hook to the React SDK, exposing all current flag values while wrapping them in a proxy that triggers client.variation on each flag read (with per-key caching) so evaluation events are recorded, and re-creating the proxy on context/identity changes.

Exports the new hook from client/index.ts, adds Jest coverage for subscription/unsubscription, re-render behavior, deprecation warning logging, proxy caching semantics, and cache reset on context changes, and hardens contract-tests/open-browser.mjs by retrying page.goto to avoid startup race conditions.

Written by Cursor Bugbot for commit 732bd27. This will update automatically on new commits. Configure here.


Open with Devin

@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25566 bytes
Compressed size limit: 26000
Uncompressed size: 125383 bytes

@github-actions
Copy link
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 172130 bytes
Compressed size limit: 200000
Uncompressed size: 800872 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 24212 bytes
Compressed size limit: 25000
Uncompressed size: 83755 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 21281 bytes
Compressed size limit: 24000
Uncompressed size: 110213 bytes

@joker23 joker23 force-pushed the skz/sdk-1993/deprecated-hooks branch from 2c96e42 to df5b8a6 Compare March 10, 2026 00:43
@joker23
Copy link
Contributor Author

joker23 commented Mar 10, 2026

@cursor review

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation changes starts here

@joker23 joker23 force-pushed the skz/sdk-1993/deprecated-hooks branch from 8e0d270 to 9311409 Compare March 10, 2026 18:09
@joker23 joker23 marked this pull request as ready for review March 10, 2026 19:48
@joker23 joker23 requested a review from a team as a code owner March 10, 2026 19:48
});

await page.goto(url);
// Retry page.goto until the entity is ready (race-condition guard)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me a smidge nervous.

Copy link
Contributor Author

@joker23 joker23 Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in lieu of waiting for the browser ready in the the workflow

* @deprecated Use `useLDClient` with the client's variation methods directly. This hook will be
* removed in a future major version.
*/
export function useFlags<T extends LDFlagSet = LDFlagSet>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work with Camelization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will address Camelization in SDK-2014. Does this mean we will need to proxy client.allFlags to support this? Not sure if it makes much sense doing that anywhere else.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

cursor[bot]

This comment was marked as resolved.

@joker23 joker23 merged commit 9756e75 into main Mar 13, 2026
44 of 47 checks passed
@joker23 joker23 deleted the skz/sdk-1993/deprecated-hooks branch March 13, 2026 16:06
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.

2 participants