reboot alterflixhub
This commit is contained in:
commit
1e84023a44
188 files changed
+31629
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { createContext, useContext, type ReactNode } from "react";
|
||||
|
||||
import type { ContentStore } from "@/lib/content-types";
|
||||
|
||||
const ContentContext = createContext<ContentStore | null>(null);
|
||||
|
||||
/** เนื้อหาที่แก้ได้ (โรงหนัง/คำศัพท์/footer) จาก loader ของ root */
|
||||
export function ContentProvider({
|
||||
content,
|
||||
children,
|
||||
}: {
|
||||
content: ContentStore;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<ContentContext.Provider value={content}>{children}</ContentContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useContent(): ContentStore {
|
||||
const value = useContext(ContentContext);
|
||||
if (!value) throw new Error("useContent ต้องถูกใช้ภายใน <ContentProvider>");
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user