@@ -99,27 +99,26 @@ export function ClerkContextProvider(props: ClerkContextProvider) {
9999} 
100100
101101const  useLoadedIsomorphicClerk  =  ( options : IsomorphicClerkOptions )  =>  { 
102-  const  isomorphicClerk  =  React . useMemo ( ( )   =>   IsomorphicClerk . getOrCreateInstance ( options ) ,   [ ] ) ; 
103-  const  [ clerkStatus ,  setStatus ]  =  React . useState ( isomorphicClerk . status ) ; 
102+  const  isomorphicClerkRef  =  React . useRef ( IsomorphicClerk . getOrCreateInstance ( options ) ) ; 
103+  const  [ clerkStatus ,  setClerkStatus ]  =  React . useState ( isomorphicClerkRef . current . status ) ; 
104104
105105 React . useEffect ( ( )  =>  { 
106-  void  isomorphicClerk . __unstable__updateProps ( {  appearance : options . appearance  } ) ; 
106+  void  isomorphicClerkRef . current . __unstable__updateProps ( {  appearance : options . appearance  } ) ; 
107107 } ,  [ options . appearance ] ) ; 
108108
109109 React . useEffect ( ( )  =>  { 
110-  void  isomorphicClerk . __unstable__updateProps ( {  options } ) ; 
110+  void  isomorphicClerkRef . current . __unstable__updateProps ( {  options } ) ; 
111111 } ,  [ options . localization ] ) ; 
112112
113113 React . useEffect ( ( )  =>  { 
114-  isomorphicClerk . on ( 'status' ,  setStatus ) ; 
115-  return  ( )  =>  isomorphicClerk . off ( 'status' ,  setStatus ) ; 
116-  } ,  [ isomorphicClerk ] ) ; 
117- 
118-  React . useEffect ( ( )  =>  { 
114+  isomorphicClerkRef . current . on ( 'status' ,  setClerkStatus ) ; 
119115 return  ( )  =>  { 
116+  if  ( isomorphicClerkRef . current )  { 
117+  isomorphicClerkRef . current . off ( 'status' ,  setClerkStatus ) ; 
118+  } 
120119 IsomorphicClerk . clearInstance ( ) ; 
121120 } ; 
122121 } ,  [ ] ) ; 
123122
124-  return  {  isomorphicClerk,  clerkStatus } ; 
123+  return  {  isomorphicClerk :  isomorphicClerkRef . current ,  clerkStatus } ; 
125124} ; 
0 commit comments