diff --git a/src/useSecrets.ts b/src/useSecrets.ts index f10d0f2..4a3565e 100644 --- a/src/useSecrets.ts +++ b/src/useSecrets.ts @@ -10,9 +10,8 @@ export function useSecrets(namespace: string) { const id = `secrets.${namespace}`; - let subscription: any; useEffect(() => { - subscription = client.observable + let subscription = client.observable .listen(query, { id }, { visibility: 'query' }) .subscribe((result: Record) => { setSecrets(result?.result?.secrets); @@ -20,7 +19,7 @@ export function useSecrets(namespace: string) { return () => { subscription.unsubscribe(); }; - }, []); + }, [id]); useEffect(() => { async function fetchData() { @@ -30,7 +29,7 @@ export function useSecrets(namespace: string) { .finally(() => setLoading(false)); } fetchData(); - }, []); + }, [id]); const storeSecrets = (secrets: T) => { setLoading(true);