import * as React from 'react' ; import { RootState , Subscription } from './types' ; /**
 * Internal OGL context.
 */ export const OGLContext = React . createContext < RootState | null > ( null ) ; /**
 * Accesses internal OGL state.
 */ export const useOGL = ( ) => { const state = React . useContext ( OGLContext ) ; if ( ! state ) throw 'Hooks must used inside a canvas or OGLContext provider!' ; return state ; } ; /**
 * Subscribe an element into a shared render loop.
 */ export const useFrame = ( callback , renderPriority = 0 ) => { const state = useOGL ( ) ; const ref = React . useRef ( callback ) ; React . useLayoutEffect ( ( ) => void ( ref . current = callback ) , [ callback ] ) ; React . useLayoutEffect ( ( ) => { state . subscribe ( ref , renderPriority ) ; return ( ) => void state . unsubscribe ( ref , renderPriority ) ; } , [ state , renderPriority ] ) ; } ;