react-code-canvas
Version:
A browser-based canvas for rendering React components at runtime
18 lines (17 loc) • 820 B
TypeScript
import { UseRunnerProps } from './useRunner';
import { UseRunnerReturn } from './useRunner';
export type UseLiveRunnerProps = Omit<UseRunnerProps, 'code'> & {
/** initial code for the live runner */
initialCode?: string;
/** transform the code before transpiling */
transformCode?: (code: string) => string;
/** localStorage key to persist edited code across reloads; omit to disable */
persistKey?: string;
/** called whenever the code changes (e.g. the user edits in the editor) */
onCodeChange?: (code: string) => void;
};
export type UseLiveRunnerRetrun = UseRunnerReturn & {
code: string;
onChange: (value: string) => void;
};
export declare const useLiveRunner: ({ initialCode, transformCode, persistKey, onCodeChange, ...rest }: UseLiveRunnerProps) => UseLiveRunnerRetrun;