Open pramahaditamaputra-ralali opened 3 years ago
this one i tried, but i dont know if this is the best practice or not
Hi @pramahaditamaputra-ralali,
You're correct that client.allFlags()
will give you all of the currently-identified user's flags, but what you're likely after is an easy way to make these flags accessible to your React context. In order to do this we'd first want to add proper provider support using the React context pattern. We have an open feature request to add this feature. I added a note to our corresponding internal ticket (79104) to mention your hooks feature request. I will leave this GitHub issue open until your feature request is resolved.
Secondly, regarding your desire for a common initialization function -- the client.configure
method is only intended to be called once, more specifically at application start time. During initialization the SDK creates long-lived connections with LaunchDarkly and these connections are meant to support feature flagging throughout your application. This function is not intended to be called in each of your components of files to initialize separate LaunchDarkly instances. Our recommendation would be to create a singleton instance and then to add it to your application context such that it is passed through your components and accessible.
Lastly, for future reference, this repository is only intended as a sample application and not our main issue tracker for the React Native SDK. Each of our SDKs are open-source and have separate repositories. For future issues with the React Native SDK I recommend filing issues here.
Cheers, @bwoskow-ld
It doesn't look like we're getting a hooks enabled version anytime soon which sadly makes this example and LD in general not very suitable for a lot of react native projects.
Hi guys, could you help to update the current example or create a new one using React Native Hooks 🙏🏻 ? and also give the best practices for make a helper function to init the sdk, so i dont need to write init to each file to use the client instance.
Thank you in advance 🙏🏻