import { createContext, useContext } from 'react' export const WidgetContext = createContext(null) export function useWidgetId(): string { const id = useContext(WidgetContext) if (id == null) { throw new Error( 'useWidgetId() must be called inside . ' + 'If you are calling from outside the Provider tree, use the hooks ' + '(useWidget, useWidgetShallow, useTransform) directly with an explicit id.', ) } return id }