Skip to content

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Jan 30, 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-1792

Describe the solution you've provided

  • change the use variation hooks to register on change listeners
  • changes in flags no longer changes the ldclient context

Describe alternatives you've considered

I think this change may require a major version, but we can probably avoid that with some compromises.

Additional context

There is a testing gap here and I will create some tasks to address. I want to do this in a different PR because I would like to refactor RN unit test to use https://oss.callstack.com/react-native-testing-library/ instead of the react testing library.

We also need to revisit the detox test, from some research it seems like detox is the correct technology for e2e testing, but we may want to revisit how to plug in to the sdk test harness (and deprecate the example testing)


Note

Medium Risk
Changes how flag updates propagate (from context updates to per-hook subscriptions), which can affect rendering behavior and relies on correct event listener management.

Overview
Ensures the LDProvider context value no longer changes on flag updates by removing the change listener/state indirection (setupListeners) and memoizing { client } instead.

Moves reactivity to the flag hooks: useTypedVariation and useTypedVariationDetail now keep local state, subscribe to the client’s change event, and update only when the evaluated value changes (with proper off cleanup), while still normalizing reason to null when absent.

Removes the setupListeners unit test and updates the LDProvider test to stop mocking setupListeners.

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

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 23264 bytes
Compressed size limit: 25000
Uncompressed size: 80869 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: 18984 bytes
Compressed size limit: 20000
Uncompressed size: 98086 bytes

@joker23 joker23 force-pushed the skz/react-native-rendering branch 4 times, most recently from 5936ae2 to baed8fb Compare January 30, 2026 15:36
break;
}

if (newValue !== valueRef.current) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Object types will still run into problems since they will not test equal, but I think it is still an improvement from before.

We can look into doing a deeper compare

@joker23 joker23 marked this pull request as ready for review January 30, 2026 15:38
@joker23 joker23 requested a review from a team as a code owner January 30, 2026 15:38
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.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@joker23 joker23 force-pushed the skz/react-native-rendering branch from baed8fb to 152a584 Compare January 30, 2026 16:46
@joker23 joker23 force-pushed the skz/react-native-rendering branch from 152a584 to 2086a07 Compare January 30, 2026 18:37
return () => {
ldClient.off('change', handleChange);
};
}, [key]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe we would want to reregister if defaultValue changes?

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