Skip to content

Commit 7b9fadb

Browse files
fix: RLN implementation
1 parent 67b8723 commit 7b9fadb

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

examples/keystore-management/src/contexts/RLNUnifiedHook.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,35 @@ export function UnifiedRLNProvider({ children }: { children: ReactNode }) {
4242
const fetchContext = async () => {
4343
try {
4444
if (implementation === 'standard') {
45-
// Import the standard RLN context
45+
// Import the standard RLN hook
4646
const standardModule = await import('./RLNContext');
47-
const standardRLNContext = standardModule.RLNContext;
47+
const { useRLN: useStandardRLN } = standardModule;
4848

49-
if (standardRLNContext) {
50-
// Access the context value
51-
const contextConsumer = standardRLNContext.Consumer;
52-
contextConsumer(value => {
53-
if (value) {
54-
setContextValue(value);
55-
}
56-
});
49+
// Create a temporary component to access the context
50+
function TempComponent() {
51+
const context = useStandardRLN();
52+
setContextValue(context);
53+
return null;
5754
}
55+
56+
// Render the component within the provider
57+
const { RLNProvider } = standardModule;
58+
return <RLNProvider><TempComponent /></RLNProvider>;
5859
} else {
59-
// Import the light RLN context
60+
// Import the light RLN hook
6061
const lightModule = await import('./RLNLightContext');
61-
const lightRLNContext = lightModule.RLNContext;
62+
const { useRLN: useLightRLN } = lightModule;
6263

63-
if (lightRLNContext) {
64-
// Access the context value
65-
const contextConsumer = lightRLNContext.Consumer;
66-
contextConsumer(value => {
67-
if (value) {
68-
setContextValue(value);
69-
}
70-
});
64+
// Create a temporary component to access the context
65+
function TempComponent() {
66+
const context = useLightRLN();
67+
setContextValue(context);
68+
return null;
7169
}
70+
71+
// Render the component within the provider
72+
const { RLNProvider } = lightModule;
73+
return <RLNProvider><TempComponent /></RLNProvider>;
7274
}
7375
} catch (error) {
7476
console.error('Error loading RLN context:', error);

0 commit comments

Comments
 (0)