From 7b9fadb21a6db54b37a7c6e92756027fb1608dc6 Mon Sep 17 00:00:00 2001 From: Danish Arora Date: Mon, 17 Mar 2025 13:41:33 +0530 Subject: [PATCH] fix: RLN implementation --- .../src/contexts/RLNUnifiedHook.tsx | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/examples/keystore-management/src/contexts/RLNUnifiedHook.tsx b/examples/keystore-management/src/contexts/RLNUnifiedHook.tsx index 25678bb..9d1533a 100644 --- a/examples/keystore-management/src/contexts/RLNUnifiedHook.tsx +++ b/examples/keystore-management/src/contexts/RLNUnifiedHook.tsx @@ -42,33 +42,35 @@ export function UnifiedRLNProvider({ children }: { children: ReactNode }) { const fetchContext = async () => { try { if (implementation === 'standard') { - // Import the standard RLN context + // Import the standard RLN hook const standardModule = await import('./RLNContext'); - const standardRLNContext = standardModule.RLNContext; + const { useRLN: useStandardRLN } = standardModule; - if (standardRLNContext) { - // Access the context value - const contextConsumer = standardRLNContext.Consumer; - contextConsumer(value => { - if (value) { - setContextValue(value); - } - }); + // Create a temporary component to access the context + function TempComponent() { + const context = useStandardRLN(); + setContextValue(context); + return null; } + + // Render the component within the provider + const { RLNProvider } = standardModule; + return ; } else { - // Import the light RLN context + // Import the light RLN hook const lightModule = await import('./RLNLightContext'); - const lightRLNContext = lightModule.RLNContext; + const { useRLN: useLightRLN } = lightModule; - if (lightRLNContext) { - // Access the context value - const contextConsumer = lightRLNContext.Consumer; - contextConsumer(value => { - if (value) { - setContextValue(value); - } - }); + // Create a temporary component to access the context + function TempComponent() { + const context = useLightRLN(); + setContextValue(context); + return null; } + + // Render the component within the provider + const { RLNProvider } = lightModule; + return ; } } catch (error) { console.error('Error loading RLN context:', error);