Open TeddyBo opened 7 months ago
Hi!
"useUser" hook has "id" as an input argument
function useUser (id) { const { data, error, isLoading } = useSWR(`/api/user/${id}`, fetcher) return { user: data, isLoading, isError: error } }
but components "Avatar" and "Content" call it without arguments.
function Content () { const { user, isLoading } = useUser() if (isLoading) return <Spinner /> return <h1>Welcome back, {user.name}</h1> }
How does it work?
Thank you! This example should be useUser(id), I'll fix it.
useUser(id)
Hi!
"useUser" hook has "id" as an input argument
but components "Avatar" and "Content" call it without arguments.
How does it work?