Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/start/framework/react/guide/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ type AuthContextType = {
const AuthContext = createContext<AuthContextType | undefined>(undefined)

export function AuthProvider({ children }: { children: ReactNode }) {
const { data: user, isLoading, refetch } = useServerFn(getCurrentUserFn)

const { data: user, isLoading, refetch } = useQuery({
queryKey: ["auth"],
queryFn: useServerFn(getCurrentUserFn),
})
Comment on lines +146 to +149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Missing useQuery import statement.

The example uses useQuery at line 146 but the code block doesn't import it. This will cause a runtime error for developers copying the example. Add the import at the top of the code block.

Apply this diff to add the missing import:

 // contexts/auth.tsx
 import { createContext, useContext, ReactNode } from 'react'
 import { useServerFn } from '@tanstack/react-start'
+import { useQuery } from '@tanstack/react-query'
 import { getCurrentUserFn } from '../server/auth'

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In docs/start/framework/react/guide/authentication.md around lines 146 to 149,
the example uses useQuery but does not import it; add an import for useQuery
from the React Query package (e.g., @tanstack/react-query) at the top of the
code block so the example runs without a runtime error.

return (
<AuthContext.Provider value={{ user, isLoading, refetch }}>
{children}
Expand Down