This is a simple repo to reproduce an unexpected LaunchDarkly issue in React Native.
Using the latest @launchdarkly/react-native-client-sdk
, the on('change', ...)
event handler is firing unrelated to identify()
calls for older context updates.
This is an example sequence:
- Call to
identify({ user: { ... } })
'change'
event is triggered with the correct variants for the previousidentify()
call (egmica-banner: false
).- Call to
identify({ user: { ... }, network: { country: "Portugal" } })
'change'
event is triggered again, now with the correct variants for the previousidentify()
call (egmica-banner: true
).'change'
event is unexpectedly triggered again, but now with the variants of the firstidentify()
call, thus reverting the previous correct feature flag state (egmica-banner: false
).'change'
event is unexpectedly triggered once again, now with the variants of the secondidentify()
call, fixing the flag state again (egmica-banner: true
).
This behaviour varies. Sometimes 'change'
is only triggered twice, as expected. Sometimes it's 3 times, sometimes 4 and even more.
In summary, we can't trust our feature flags to evaluate to the expected final variant.
-
Install dependencies
npm install
-
Start the app
EXPO_PUBLIC_LD_PRODUCTION_MOBILE_KEY=mob-.... npx expo start
In the output, you'll see LdTest ...
messages showing what's going on.
- Create a new Expo project:
npx create-expo-app@latest
- Copy the
FeatureFlagTest/
folder of this repo to your new project - Instance the reproduction component
<FeatureFlagTest />
(Example in this repo) npm i
npm i @launchdarkly/react-native-client-sdk@latest
To run it in dev mode where the issue is reproducible:
EXPO_PUBLIC_LD_PRODUCTION_MOBILE_KEY=mob-.... npx expo start
To run it in prod mode where the issue is NOT reproducible:
EXPO_PUBLIC_LD_PRODUCTION_MOBILE_KEY=mob-.... npx expo run:ios --configuration Release