@@ -42,33 +42,35 @@ export function UnifiedRLNProvider({ children }: { children: ReactNode }) {
42
42
const fetchContext = async ( ) => {
43
43
try {
44
44
if ( implementation === 'standard' ) {
45
- // Import the standard RLN context
45
+ // Import the standard RLN hook
46
46
const standardModule = await import ( './RLNContext' ) ;
47
- const standardRLNContext = standardModule . RLNContext ;
47
+ const { useRLN : useStandardRLN } = standardModule ;
48
48
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 ;
57
54
}
55
+
56
+ // Render the component within the provider
57
+ const { RLNProvider } = standardModule ;
58
+ return < RLNProvider > < TempComponent /> </ RLNProvider > ;
58
59
} else {
59
- // Import the light RLN context
60
+ // Import the light RLN hook
60
61
const lightModule = await import ( './RLNLightContext' ) ;
61
- const lightRLNContext = lightModule . RLNContext ;
62
+ const { useRLN : useLightRLN } = lightModule ;
62
63
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 ;
71
69
}
70
+
71
+ // Render the component within the provider
72
+ const { RLNProvider } = lightModule ;
73
+ return < RLNProvider > < TempComponent /> </ RLNProvider > ;
72
74
}
73
75
} catch ( error ) {
74
76
console . error ( 'Error loading RLN context:' , error ) ;
0 commit comments