ui enhancements
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useContext } from "react";
|
||||
import type { PublicProfile } from "@/lib/social";
|
||||
|
||||
/** Set by the /u/[handle] layout after it fetches the profile. Child
|
||||
* pages read it to render content (e.g. the Collections tab needs the
|
||||
* profile's `public_collections` array) without a second fetch. */
|
||||
export const PublicProfileContext = createContext<PublicProfile | null>(null);
|
||||
|
||||
export function usePublicProfile(): PublicProfile {
|
||||
const v = useContext(PublicProfileContext);
|
||||
if (!v) {
|
||||
throw new Error(
|
||||
"usePublicProfile must be used inside the /u/[handle] layout",
|
||||
);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
Reference in New Issue
Block a user