Closed janhartmann closed 6 years ago
Holy. I got it working, the issue was I needed to update the bootstrap
state prop and not a flags
(nested) state prop. So changing to:
this.state = {
boostrap: {}
};
<LaunchDarkly
clientId={ApplicationConfiguration.launchDarklyClientId}
user={{ key: this.getUserKey() }}
clientOptions={{ boostrap }}
>
{children}
</LaunchDarkly>
And fetch like:
const flags = await getAllFeatureFlags(
ApplicationConfiguration.launchDarklyClientId,
{
key: this.getUserKey()
}
);
this.setState({
boostrap: {
flags
}
});
Guess I was updating a nested prop and not triggering an update.
First of all, thanks for this great integration
I am in a situation where I do a hard reload of a page with has a React Router
FeatureFlag
, thegetAllFeatureFlags
returns an empty object and therefore not rendering therenderFeatureCallback
. After debugging this theuserKey
is set correctly on thegetAllFeatureFlags
request, but theFeatureFlag
returns therenderDefaultCallback
response.If I click around the routes of the application (even after a hard reload), to pages with
FeatureFlag
's it all works fine. I am unsure whether or not I am using this library wrong, or I have some issues with my routing. Any suggestions is much appreciated. I know there is many moving parts.Hard reloading on routes without a
<FeatureFlag />
wrapper, works just fine.My setup is that I wrap the
<LaunchDarkly ... />
in a wrapper:This setup is then wired into the application, and it functions fine. Now I toggle my React Router routes like so:
My composition root of the applications is like
With the
App
component looking like: