| 123456789101112131415161718192021222324252627282930313233 |
- 'use client';
- import { createContext, useContext } from 'react';
- type StudioContextValue = {
- channelID: number|null;
- memberID: number;
- };
- const StudioContext = createContext<StudioContextValue|null>(null);
- export function useStudioContext(): StudioContextValue {
- const ctx = useContext(StudioContext);
- if (!ctx) {
- throw new Error('useStudioContext must be used within StudioProvider');
- }
- return ctx;
- }
- type Props = {
- channelID: number|null;
- memberID: number;
- children: React.ReactNode;
- };
- export function StudioProvider({ channelID, memberID, children }: Props) {
- return (
- <StudioContext.Provider value={{ channelID, memberID }}>
- {children}
- </StudioContext.Provider>
- );
- }
|