Skip to content

Commit 5f059f1

Browse files
committed
fixup: feedback
Signed-off-by: Todd Baert <[email protected]>
1 parent e9ed5d0 commit 5f059f1

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/react/src/context/use-context-mutator.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,38 @@ import { Context } from '../common';
55

66
export type ContextMutationOptions = {
77
/**
8-
* Apply changes to the default context instead of the domain scoped context applied at the <OpenFeatureProvider/>.
9-
* Note, if the <OpenFeatureProvider/> has no domain specified, the default is used.
8+
* Mutate the default context instead of the domain scoped context applied at the `<OpenFeatureProvider/>`.
9+
* Note, if the `<OpenFeatureProvider/>` has no domain specified, the default is used.
10+
* See the {@link https://openfeature.dev/docs/reference/technologies/client/web/#manage-evaluation-context-for-domains|documentation} for more information.
11+
* @default false
1012
*/
11-
default?: boolean;
13+
defaultContext?: boolean;
1214
};
1315

1416
export type ContextMutation = {
1517
/**
1618
* A function to set the desired context (see: {@link ContextMutationOptions} for details).
19+
* There's generally no need to await the result of this function; flag evaluation hooks will re-render when the context is updated.
20+
* This promise never rejects.
1721
* @param updatedContext
18-
* @returns
22+
* @returns Promise for awaiting the context update
1923
*/
20-
setContext: (updatedContext: EvaluationContext) => Promise<void>
24+
setContext: (updatedContext: EvaluationContext) => Promise<void>;
2125
};
2226

2327
/**
2428
* Get function(s) for mutating the evaluation context associated with this domain, or the default context if `global: true`.
29+
* See the {@link https://openfeature.dev/docs/reference/technologies/client/web/#targeting-and-context|documentation} for more information.
2530
* @param {ContextMutationOptions} options options for the generated function
2631
* @returns {ContextMutation} function(s) to mutate context
2732
*/
28-
export function useContextMutator(options: ContextMutationOptions = {}): ContextMutation {
33+
export function useContextMutator(options: ContextMutationOptions = { defaultContext: false }): ContextMutation {
2934
const { domain } = useContext(Context) || {};
3035
const previousContext = useRef<null | EvaluationContext>(null);
3136

3237
const setContext = useCallback(async (updatedContext: EvaluationContext) => {
3338
if (previousContext.current !== updatedContext) {
34-
if (!domain || options?.default) {
39+
if (!domain || options?.defaultContext) {
3540
OpenFeature.setContext(updatedContext);
3641
} else {
3742
OpenFeature.setContext(domain, updatedContext);

0 commit comments

Comments
 (0)