import { createContext, useContext } from 'react' /** @experimental This API is new and may change in a future release. */ export const LegendContext = createContext(null) /** @experimental This API is new and may change in a future release. */ export function useLegendId(): string { const id = useContext(LegendContext) if (id == null) { throw new Error( 'useLegendId() must be called inside . ' + 'If you are calling from outside the Provider tree, use the hooks ' + '(useLegendStore, useLegendShallow) directly with an explicit id.', ) } return id }