Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

766 B
Raw Blame
import { BuiltLogic } from 'kea'
import { createContext, useContext } from 'react'

import type { notebookNodeLogicType } from './notebookNodeLogic'

export const NotebookNodeContext = createContext<BuiltLogic<notebookNodeLogicType> | undefined>(undefined)

// Currently there is no way to optionally get bound logics so this context allows us to maybe get a logic if it is "bound" via the provider
export const useNotebookNode = (): BuiltLogic<notebookNodeLogicType> | undefined => {
    return useContext(NotebookNodeContext)
}

export const useRequiredNotebookNode = (): BuiltLogic<notebookNodeLogicType> => {
    const nodeLogic = useNotebookNode()
    if (!nodeLogic) {
        throw new Error('Notebook node context is required')
    }

    return nodeLogic
}