1- import React , { useContext , useEffect , useState } from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import { render , screen } from '@testing-library/react' ;
33import { type Mock } from 'vitest' ;
44import { UnleashClient , type IVariant , EVENTS } from 'unleash-proxy-client' ;
55import FlagProvider from './FlagProvider' ;
6- import FlagContext from './FlagContext ' ;
6+ import { useFlagContext } from './useFlagContext ' ;
77import '@testing-library/jest-dom' ;
88
99const getVariantMock = vi . fn ( ) . mockReturnValue ( 'A' ) ;
@@ -44,8 +44,7 @@ vi.mock('unleash-proxy-client', async (importOriginal) => {
4444const noop = ( ) => { } ;
4545
4646const FlagConsumerAfterClientInit = ( ) => {
47- const { updateContext, isEnabled, getVariant, client, on } =
48- useContext ( FlagContext ) ;
47+ const { updateContext, isEnabled, getVariant, client, on } = useFlagContext ( ) ;
4948 const [ enabled , setIsEnabled ] = useState ( false ) ;
5049 const [ variant , setVariant ] = useState < IVariant | null > ( null ) ;
5150 const [ context , setContext ] = useState < any > ( 'nothing' ) ;
@@ -71,8 +70,7 @@ const FlagConsumerAfterClientInit = () => {
7170} ;
7271
7372const FlagConsumerBeforeClientInit = ( ) => {
74- const { updateContext, isEnabled, getVariant, client, on } =
75- useContext ( FlagContext ) ;
73+ const { updateContext, isEnabled, getVariant, client, on } = useFlagContext ( ) ;
7674 const [ enabled , setIsEnabled ] = useState ( false ) ;
7775 const [ variant , setVariant ] = useState < IVariant | null > ( null ) ;
7876 const [ context , setContext ] = useState < any > ( 'nothing' ) ;
@@ -162,8 +160,7 @@ test('A memoized consumer should not rerender when the context provider values a
162160 const renderCounter = vi . fn ( ) ;
163161
164162 const MemoizedConsumer = React . memo ( ( ) => {
165- const { updateContext, isEnabled, getVariant, client, on } =
166- useContext ( FlagContext ) ;
163+ const { updateContext, isEnabled, getVariant, client, on } = useFlagContext ( ) ;
167164
168165 renderCounter ( ) ;
169166
0 commit comments