Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b30cd25

Browse files
authoredApr 11, 2025··
revert context method changes (#201)
1 parent 557f32d commit b30cd25

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed
 

‎src/FlagProvider.tsx

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import React, { type FC, type PropsWithChildren, useCallback, useEffect, useMemo, useState } from 'react';
3+
import React, { type FC, type PropsWithChildren, useEffect, useMemo, useState } from 'react';
44
import { type IConfig, IMutableContext, UnleashClient } from 'unleash-proxy-client';
55
import FlagContext, { type IFlagContextValue } from './FlagContext';
66

@@ -106,40 +106,21 @@ const FlagProvider: FC<PropsWithChildren<IFlagProvider>> = ({
106106
};
107107
}, []);
108108

109-
const on = useCallback<IFlagContextValue['on']>(client.current.on, []);
110-
111-
const off = useCallback<IFlagContextValue['off']>(client.current.off, []);
112-
113-
const isEnabled = useCallback<IFlagContextValue['isEnabled']>(
114-
(toggleName: string) => client.current.isEnabled(toggleName),
115-
[]
116-
)
117-
118-
const updateContext = useCallback<IFlagContextValue['updateContext']>(
119-
async (context: IMutableContext) =>
120-
await client.current.updateContext(context),
121-
[]
122-
)
123-
124-
const getVariant = useCallback<IFlagContextValue['getVariant']>(
125-
(toggleName: string) => client.current.getVariant(toggleName),
126-
[]
127-
)
128-
129109
const context = useMemo<IFlagContextValue>(
130110
() => ({
131-
on,
132-
off,
133-
updateContext,
134-
isEnabled,
135-
getVariant,
111+
on: (...args) => client.current.on(...args),
112+
off: (...args) => client.current.off(...args),
113+
isEnabled: (...args) => client.current.isEnabled(...args),
114+
updateContext: async (...args) =>
115+
await client.current.updateContext(...args),
116+
getVariant: (...args) => client.current.getVariant(...args),
136117
client: client.current,
137118
flagsReady,
138119
flagsError,
139120
setFlagsReady,
140121
setFlagsError,
141122
}),
142-
[flagsReady, flagsError, on, off, updateContext, isEnabled, getVariant]
123+
[flagsReady, flagsError]
143124
);
144125

145126
return (

0 commit comments

Comments
 (0)
Please sign in to comment.