StiffJobs
StiffJobs5h ago

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.
2 Replies
Convex Bot
Convex Bot5h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart1h ago
Is the code you're ignoring related to auth? Sounds like when the code is ignored auth is being held up, but that's mostly a guess based on the description

Did you find this page helpful?