Skip to content

Commit

Permalink
RECONCILING instead of STALE
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Mar 1, 2024
1 parent fb2eb73 commit f17531a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/react/src/use-feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ReactFlagEvaluationOptions = {
* Set to true if you want to show suspense fallbacks while flags are re-evaluated after context changes.
* Defaults to false.
*/
suspendWhileStale?: boolean,
suspendWhileReconciling?: boolean,
/**
* Update the component if the provider emits a ConfigurationChanged event.
* Set to false to prevent components from re-rendering when flag value changes
Expand All @@ -35,7 +35,7 @@ const DEFAULT_OPTIONS: ReactFlagEvaluationOptions = {
updateOnContextChanged: true,
updateOnConfigurationChanged: true,
suspendUntilReady: true,
suspendWhileStale: false,
suspendWhileReconciling: false,
};

enum SuspendState {
Expand Down Expand Up @@ -177,15 +177,15 @@ function attachHandlersAndResolve<T extends FlagValue>(flagKey: string, defaultV
if (defaultedOptions.updateOnContextChanged) {
// update when the context changes
client.addHandler(ProviderEvents.ContextChanged, forceUpdate);
if (defaultedOptions.suspendWhileStale) {
client.addHandler(ProviderEvents.Stale, suspendRef);
if (defaultedOptions.suspendWhileReconciling) {
client.addHandler(ProviderEvents.Reconciling, suspendRef);
}
}
return () => {
// cleanup the handlers
client.removeHandler(ProviderEvents.Ready, forceUpdate);
client.removeHandler(ProviderEvents.ContextChanged, forceUpdate);
client.removeHandler(ProviderEvents.Stale, suspendRef);
client.removeHandler(ProviderEvents.Reconciling, suspendRef);
};
}, []);

Expand Down

0 comments on commit f17531a

Please sign in to comment.