@@ -4,20 +4,23 @@ import {
44 PropsWithChildren ,
55 ReactNode ,
66 useEffect ,
7+ useMemo ,
78 useRef ,
89 useState
910} from 'react'
1011import {
12+ DefaultVariationEventPayload ,
1113 Evaluation ,
1214 Event as FFEvent ,
1315 initialize ,
1416 Options ,
1517 Result as InitializeResult ,
16- Target ,
17- DefaultVariationEventPayload
18+ Target
1819} from '@harnessio/ff-javascript-client-sdk'
1920import omit from 'lodash.omit'
2021
22+ export { Event } from '@harnessio/ff-javascript-client-sdk'
23+
2124export interface FFContextValue {
2225 loading : boolean
2326 flags : Record < string , any >
@@ -33,7 +36,7 @@ export type NetworkError =
3336 | FFEvent . ERROR_FETCH_FLAGS
3437 | FFEvent . ERROR_METRICS
3538
36- export interface FFContextProviderProps extends PropsWithChildren {
39+ export interface FFContextProviderProps extends PropsWithChildren < unknown > {
3740 apiKey : string
3841 target : Target
3942 options ?: Options
@@ -157,11 +160,26 @@ export const FFContextProvider: FC<FFContextProviderProps> = ({
157160 client . close ( )
158161 }
159162 }
160- } , [ apiKey , JSON . stringify ( target ) , initialEvaluations ] )
163+ } , [
164+ apiKey ,
165+ JSON . stringify ( target ) ,
166+ initialEvaluations ,
167+ options ?. baseUrl ,
168+ options ?. eventUrl ,
169+ options ?. streamEnabled ,
170+ options ?. pollingEnabled
171+ ] )
172+
173+ const value = useMemo (
174+ ( ) => ( { loading, flags, client : clientInstance } ) ,
175+ [ loading , flags , clientInstance ]
176+ )
161177
162178 return (
163- < FFContext . Provider value = { { loading , flags , client : clientInstance } } >
179+ < FFContext . Provider value = { value } >
164180 { ! asyncMode && loading ? fallback : children }
165181 </ FFContext . Provider >
166182 )
167183}
184+
185+ FFContextProvider . displayName = 'FFContextProvider'
0 commit comments