Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide example of using LaunchDarkly with React Native Hooks 🙏🏻 #21

Open
pramahaditamaputra-ralali opened this issue Sep 20, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@pramahaditamaputra-ralali

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 🙏🏻

@pramahaditamaputra-ralali
Copy link
Author

pramahaditamaputra-ralali commented Sep 20, 2021

this one i tried, but i dont know if this is the best practice or not

Screen Shot 2021-09-20 at 12 58 15

@bwoskow-ld bwoskow-ld added the enhancement New feature or request label Sep 25, 2021
@bwoskow-ld
Copy link
Member

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

@Maltronic
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants