feat: Support for providing custom contexts #313
Merged
+257
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
How do I validate my changes against all supported platform versions?
Related issues
#127
Describe the solution you've provided
This PR enables developers to provide a custom React Context to the React SDK along-side a pre-initialized LDClient object. This allows applications to create one client per environment and/or project and create a unique React Context that corresponds with each client.
Also, in a microfrontend situation where multiple independent React applications are loaded on the same page, this custom React Context feature would allow a parent application to create the client and associated React Context. Then any child application loaded on the page could leverage those existing client and context objects.
Here's an example of how the React Contexts can be used together:
Describe alternatives you've considered
I am unaware of alternatives to providing a custom React context into the library because this library creates its own context at runtime.
Additional context