mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
fix: namespace flag-repo for unleash sdk (#9910)
Did two things: 1. Use basePath to prefix the Unleash repo used with the Unleash Frontend SDK. 2. Use JSON.stringify as key for useEffect to avoid potential render loop
This commit is contained in:
parent
a7118e0c18
commit
28373f5e37
@ -1,7 +1,11 @@
|
||||
import type React from 'react';
|
||||
import { type FC, useEffect } from 'react';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import FlagProvider, { UnleashClient } from '@unleash/proxy-client-react';
|
||||
import FlagProvider, {
|
||||
LocalStorageProvider,
|
||||
UnleashClient,
|
||||
} from '@unleash/proxy-client-react';
|
||||
import { basePath } from '../../../utils/formatPath';
|
||||
|
||||
const UNLEASH_API = 'https://hosted.edge.getunleash.io/api/frontend';
|
||||
const DEV_TOKEN = '';
|
||||
@ -27,6 +31,7 @@ export const UnleashFlagProvider: FC<{ children?: React.ReactNode }> = ({
|
||||
token = getUnleashFrontendToken();
|
||||
|
||||
client = new UnleashClient({
|
||||
storageProvider: new LocalStorageProvider(`${basePath}:unleash`),
|
||||
url: UNLEASH_API,
|
||||
clientKey: token || 'offline',
|
||||
appName: 'Unleash Cloud UI',
|
||||
@ -45,7 +50,7 @@ export const UnleashFlagProvider: FC<{ children?: React.ReactNode }> = ({
|
||||
} else {
|
||||
// nothing
|
||||
}
|
||||
}, [uiConfig.unleashContext]);
|
||||
}, [JSON.stringify(uiConfig.unleashContext)]);
|
||||
|
||||
return (
|
||||
<FlagProvider unleashClient={client} startClient={false}>
|
||||
|
Loading…
Reference in New Issue
Block a user