Skip to content

Realistic watercolor drawings

TypeScript paintwatercolor
433 B
Raw Blame
import { createContext } from 'preact';
import { useContext } from 'preact/hooks';
import type { AppStore } from './store';

export const AppContext = createContext<AppStore | null>(null);

/** The app store; components are always rendered inside <AppContext.Provider>. */
export function useApp(): AppStore {
  const app = useContext(AppContext);
  if (!app) throw new Error('useApp outside <AppContext.Provider>');
  return app;
}