react-code-canvas
Version:
Package to run and preview React code with live editing capabilities in a browser.
23 lines (22 loc) • 946 B
TypeScript
import { Component, ReactElement } from 'react';
import { RunnerOptions, Scope } from './types';
export type RunnerProps = RunnerOptions & {
/** callback on code be rendered, returns error message when code is invalid */
onRendered?: (error?: Error) => void;
};
type RunnerState = {
element: ReactElement | null;
error: Error | null;
prevCode: string | null;
prevScope: Scope | undefined;
};
export declare class Runner extends Component<RunnerProps, RunnerState> {
state: RunnerState;
static getDerivedStateFromProps(props: RunnerProps, state: RunnerState): Partial<RunnerState> | null;
static getDerivedStateFromError(error: Error): Partial<RunnerState>;
componentDidMount(): void;
shouldComponentUpdate(nextProps: RunnerProps, nextState: RunnerState): boolean;
componentDidUpdate(): void;
render(): ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
}
export {};