ConvexAuth error when shouldHandleCode is false
function InnerApp() {
const { isAuthenticated, isLoading } = useConvexAuth();
const locale = window.localStorage.getItem('locale') || 'zh';
useEffect(() => {
dynamicActivate(locale);
}, [locale]);
useEffect(() => {
console.log('isloading?:', isLoading);
}, [isLoading]);
if (isLoading) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-sm text-gray-500">Loading…</div>
</div>
);
}
return (
<I18nProvider i18n={i18n}>
<RouterProvider
router={router}
context={{
queryClient,
isAuthenticated,
}}
/>
</I18nProvider>
);
}
const rootElement = document.getElementById('app');
if (rootElement && !rootElement.innerHTML) {
const root = ReactDOM.createRoot(rootElement);
root.render(
<StrictMode>
<ConvexAuthProvider
client={convex}
shouldHandleCode={() => {
console.log('path', location.pathname);
if (location.pathname.startsWith('/accounts')) {
console.log('here');
return false;
}
return true;
}}
>
<QueryClientProvider client={queryClient}>
<InnerApp />
</QueryClientProvider>
</ConvexAuthProvider>
</StrictMode>,
);
}function InnerApp() {
const { isAuthenticated, isLoading } = useConvexAuth();
const locale = window.localStorage.getItem('locale') || 'zh';
useEffect(() => {
dynamicActivate(locale);
}, [locale]);
useEffect(() => {
console.log('isloading?:', isLoading);
}, [isLoading]);
if (isLoading) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-sm text-gray-500">Loading…</div>
</div>
);
}
return (
<I18nProvider i18n={i18n}>
<RouterProvider
router={router}
context={{
queryClient,
isAuthenticated,
}}
/>
</I18nProvider>
);
}
const rootElement = document.getElementById('app');
if (rootElement && !rootElement.innerHTML) {
const root = ReactDOM.createRoot(rootElement);
root.render(
<StrictMode>
<ConvexAuthProvider
client={convex}
shouldHandleCode={() => {
console.log('path', location.pathname);
if (location.pathname.startsWith('/accounts')) {
console.log('here');
return false;
}
return true;
}}
>
<QueryClientProvider client={queryClient}>
<InnerApp />
</QueryClientProvider>
</ConvexAuthProvider>
</StrictMode>,
);
}when trying to ignore the handle code for some path in my tanstack router app, the isLoading state from the useConvexAuth keep staying true. Don't know why this happened.
