Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
2c96e42 to
df5b8a6
Compare
|
@cursor review |
There was a problem hiding this comment.
Implementation changes starts here
8e0d270 to
9311409
Compare
| @@ -0,0 +1,4 @@ | |||
| export { useFlag } from './useFlag'; | |||
There was a problem hiding this comment.
I am not sure why we need useFlag or useFlagDetail. These didn't exist in the 3.x react SDK.
| * @param reactContext Optional React context to read from. Defaults to the global `LDReactContext`. | ||
| * @returns All current flag values as `T`, wrapped in a proxy that records evaluations. | ||
| * | ||
| * @deprecated Use `useLDClient` with the client's variation methods directly. This hook will be |
There was a problem hiding this comment.
I think that the use here should be called out that this is to ease migration. That you should use the useVariation hooks.
| }); | ||
|
|
||
| await page.goto(url); | ||
| // Retry page.goto until the entity is ready (race-condition guard) |
There was a problem hiding this comment.
This makes me a smidge nervous.
| * @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>( |
There was a problem hiding this comment.
How does this work with Camelization?
| // small subset of flags. In this case, any flag updates will cause a reset of the cache. | ||
| // It is recommended to use the typed variation hooks (useBoolVariation, useStringVariation, | ||
| // useNumberVariation, useJsonVariation) for better performance when reading a subset of flags. | ||
| const cache = new Map<string, unknown>(); |
There was a problem hiding this comment.
I am not sure about the cache with regards to experiment exposure.
Requirements
Related issues
sdk-1993
Note
Medium Risk
Adds new public React hooks API surface (even if deprecated) and a proxy-based
useFlagsimplementation that could affect evaluation/event behavior; changes are covered by focused unit tests and do not touch auth/security paths.Overview
Adds a new
deprecated-hooksexport surface to the React SDK:useFlag,useFlagDetail, anduseFlagsare now available fromclient/index.tsand emit aclient.logger.warndeprecation notice on mount.useFlag/useFlagDetailprovide typed single-flag reads (dispatching to the appropriate*Variation/*VariationDetailmethod based ondefaultValue) and re-render only onchange:<key>events, whileuseFlagsreturns a proxy overclient.allFlags()that triggers (and caches)client.variationcalls on property reads and re-renders on the globalchangeevent.Adds comprehensive jsdom tests plus test wrappers to validate method dispatch, subscription/unsubscription behavior, rerender behavior on flag/context/key changes, deprecation warnings, and the
useFlagsproxy caching behavior.Written by Cursor Bugbot for commit df5b8a6. This will update automatically on new commits. Configure here.