Skip to main content

Interface: SandpackState

Properties

activeFile

activeFile: string

Path to the file will be open in the code editor when the component mounts

Defined in

sandpack-react/src/types.ts:529


bundlerState

bundlerState: undefined | BundlerState

Defined in

sandpack-react/src/types.ts:509


clients

clients: Record<string, SandpackClient>

Defined in

sandpack-react/src/types.ts:543


editorState

editorState: EditorState

Returns the current state of the editor, meaning that any changes from the original files must return a dirty value; otherwise, it'll return pristine

Defined in

sandpack-react/src/types.ts:537


environment

Optional environment: SandboxEnvironment

Defined in

sandpack-react/src/types.ts:540


error

error: null | SandpackError

Defined in

sandpack-react/src/types.ts:538


errorScreenRegisteredRef

errorScreenRegisteredRef: MutableRefObject<boolean>

eg: error screen - if no component registers this, the bundler needs to show the custom error screen When the value is boolean, we only care if the components have the responsibility to render the elements, we don't need the actual element reference

Defined in

sandpack-react/src/types.ts:571


files

files: SandpackBundlerFiles

Defined in

sandpack-react/src/types.ts:539


initMode

initMode: SandpackInitMode

Defined in

sandpack-react/src/types.ts:542


lazyAnchorRef

lazyAnchorRef: RefObject<HTMLDivElement>

Element refs Different components inside the SandpackProvider might register certain elements of interest for sandpack eg: lazy anchor - if no component registers this, then the sandpack runs on mount, without lazy mode

Defined in

sandpack-react/src/types.ts:564


loadingScreenRegisteredRef

loadingScreenRegisteredRef: MutableRefObject<boolean>

Defined in

sandpack-react/src/types.ts:573


openInCSBRegisteredRef

openInCSBRegisteredRef: MutableRefObject<boolean>

Defined in

sandpack-react/src/types.ts:572


startRoute

Optional startRoute: string

Defined in

sandpack-react/src/types.ts:530


status

status: SandpackStatus

Defined in

sandpack-react/src/types.ts:541


visibleFiles

visibleFiles: string[]

List the file path listed in the file tab, which will allow the user to interact with.

Defined in

sandpack-react/src/types.ts:515


visibleFilesFromProps

visibleFilesFromProps: string[]

List the file path listed in the file tab, Can only be changed through the properties of SandpackProvider (files/options)

internal

Defined in

sandpack-react/src/types.ts:523

Methods

addFile

addFile(pathOrFiles, code?): void

Parameters

NameType
pathOrFilesstring | SandpackFiles
code?string

Returns

void

Defined in

sandpack-react/src/types.ts:549


closeFile

closeFile(path): void

Parameters

NameType
pathstring

Returns

void

Defined in

sandpack-react/src/types.ts:552


deleteFile

deleteFile(path): void

Parameters

NameType
pathstring

Returns

void

Defined in

sandpack-react/src/types.ts:553


openFile

openFile(path): void

Parameters

NameType
pathstring

Returns

void

Defined in

sandpack-react/src/types.ts:551


registerBundler

registerBundler(iframe, clientId): void

Parameters

NameType
iframeHTMLIFrameElement
clientIdstring

Returns

void

Defined in

sandpack-react/src/types.ts:546


registerReactDevTools

registerReactDevTools(value): void

Parameters

NameType
valueReactDevToolsMode

Returns

void

Defined in

sandpack-react/src/types.ts:557


resetAllFiles

resetAllFiles(): void

Returns

void

Defined in

sandpack-react/src/types.ts:556


resetFile

resetFile(path): void

Parameters

NameType
pathstring

Returns

void

Defined in

sandpack-react/src/types.ts:555


runSandpack

runSandpack(): void

Returns

void

Defined in

sandpack-react/src/types.ts:545


setActiveFile

setActiveFile(path): void

Parameters

NameType
pathstring

Returns

void

Defined in

sandpack-react/src/types.ts:554


unregisterBundler

unregisterBundler(clientId): void

Parameters

NameType
clientIdstring

Returns

void

Defined in

sandpack-react/src/types.ts:547


updateCurrentFile

updateCurrentFile(newCode): void

Parameters

NameType
newCodestring

Returns

void

Defined in

sandpack-react/src/types.ts:550


updateFile

updateFile(pathOrFiles, code?): void

Parameters

NameType
pathOrFilesstring | SandpackFiles
code?string

Returns

void

Defined in

sandpack-react/src/types.ts:548