|
1 | 1 | /** @format */ |
2 | 2 |
|
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'; |
4 | 4 | import { type IConfig, IMutableContext, UnleashClient } from 'unleash-proxy-client'; |
5 | 5 | import FlagContext, { type IFlagContextValue } from './FlagContext'; |
6 | 6 |
|
@@ -106,40 +106,21 @@ const FlagProvider: FC<PropsWithChildren<IFlagProvider>> = ({ |
106 | 106 | }; |
107 | 107 | }, []); |
108 | 108 |
|
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 | | - |
129 | 109 | const context = useMemo<IFlagContextValue>( |
130 | 110 | () => ({ |
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), |
136 | 117 | client: client.current, |
137 | 118 | flagsReady, |
138 | 119 | flagsError, |
139 | 120 | setFlagsReady, |
140 | 121 | setFlagsError, |
141 | 122 | }), |
142 | | - [flagsReady, flagsError, on, off, updateContext, isEnabled, getVariant] |
| 123 | + [flagsReady, flagsError] |
143 | 124 | ); |
144 | 125 |
|
145 | 126 | return ( |
|
0 commit comments