UNPKG

@codesandbox/sandpack-react

Version:

<img style="width:100%" src="https://user-images.githubusercontent.com/4838076/143581035-ebee5ba2-9cb1-4fe8-a05b-2f44bd69bb4b.gif" alt="Component toolkit for live running code editing experiences" />

23 lines (22 loc) 993 B
import type { ListenerFunction, SandpackClient, SandpackMessage, UnsubscribeFunction } from "@codesandbox/sandpack-client"; import * as React from "react"; import type { ClientPropsOverride } from "../contexts/utils/useClient"; import type { SandpackState } from "../types"; interface UseSandpackClient { sandpack: SandpackState; getClient: () => InstanceType<typeof SandpackClient> | null; iframe: React.MutableRefObject<HTMLIFrameElement | null>; listen: (listener: ListenerFunction) => UnsubscribeFunction; dispatch: (message: SandpackMessage) => void; clientId: string; } /** * It registers a new sandpack client and returns its instance, * listeners, and dispatch function. Using it when creating a custom * component to interact directly with the client is recommended. * For other cases, use `useSandpack` instead. * * @category Hooks */ export declare const useSandpackClient: (clientPropsOverride?: ClientPropsOverride) => UseSandpackClient; export {};