react-client-sdk
react-client-sdk copied to clipboard
Clarify why this SDK won't work in a React Native project
I have an Expo React Native project I want to use LaunchDarkly with. However, at the moment the only build target we're using is web, using react-native-web. It's unclear to me if I should be using the React Native SDK or this SDK. This SDK explicitly says "The React SDK does not work in React Native projects", but the React Native SDK says "[...] the SDK uses native modules" (in the section about Expo managed workflows)
Describe the solution you'd like Can you clarify why this SDK won't work in a React Native project? Are there certain features I can disable or abstain from using that will let me build this to a Native compile target in the future? Are these feature I can polyfill on Native?
How do you recommend someone use LaunchDarkly when they're using react-native-web to compile a React Native project to both web and Native?
Describe alternatives you've considered For now I'll probably need to just use this SDK and cross my fingers it works when we prioritize compiling to Native in a few months. But I'd rather not introduce LaunchDarkly technical debt before I've written a single line of LaunchDarkly-specific code!
Hello @jkjustjoshing, thank you for reaching out.
In your case (React Native Web only), as of this moment, trying to use this is the best bet. LaunchDarkly hasn't tested the react-client-sdk with React Native web as part of regular testing, so we don't know would using this SDK works well for you.
The React SDK does not work in React Native projects is there to make sure mobile developers do not waste time trying this out (as React Native Mobile is a common use case of React Native). And it is correct that LaunchDarkly's current RN SDK is using native modules, so that won't work in React Native Web.
The SDK team has heard multiple feedbacks and understands this is not an ideal situation, so the SDK team is currently working on a new React Native SDK that is based on pure JavaScript without using a native module here: https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native - However, that work is still in progress and we don't have a GA ETA for the new React Native SDK yet, so I am not sure would that meet your timeline.
Thanks for the response @louis-launchdarkly.
One part of my question to make sure gets answered - when you say
"The React SDK does not work in React Native projects" is there to make sure mobile developers do not waste time trying this out
why would it be a waste of time?
Currently, there is no CircleCI or build setup to test using the React Client SDK with Android or iOS, so LaunchDarkly cannot guarantee React Client SDK can work with React Native Mobile, and cannot support it if someone finds bugs that only happen for React Client SDK with React Native.
And if I remember correctly, there is a difference in the event source libraries between browsers and Android/iOS that is likely incompatible.
But LaunchDarkly and likely some other customers would love to hear back if there is a way to make React Client SDK work with React Native, before the new React Native SDK in pure JS is completed.