ReactSketchCanvasRef
Defined in: ReactSketchCanvas/types.ts:120
Imperative ref API exposed by ReactSketchCanvas.
Remarks
Use this ref to control drawing mode, history, exports, and path loading from parent components.
Extends
Properties
clearCanvas
clearCanvas: () =>
void
Defined in: ReactSketchCanvas/types.ts:142
Remove all paths from the canvas while preserving history.
Returns
void
Nothing.
Remarks
Users can still undo back to the previous drawing after clearCanvas().
Use resetCanvas() when you want to remove paths and clear undo/redo
history.
eraseMode
eraseMode: (
erase) =>void
Defined in: ReactSketchCanvas/types.ts:131
Switch between drawing and erasing.
Parameters
erase
boolean
Whether future pointer strokes should erase.
Returns
void
Nothing.
Remarks
Passing true enables erasing for future strokes. Passing false returns
to normal drawing mode. Existing paths are not changed.
exportImage
exportImage: (
imageType,options?) =>Promise<string>
Defined in: Canvas/types.ts:243
Export the current canvas as a raster image data URL.
Parameters
imageType
Image format to create.
options?
Optional export dimensions.
Returns
Promise<string>
Promise that resolves to a data:image/* URL.
Remarks
The output includes the currently rendered strokes. Background image export
depends on the exportWithBackgroundImage prop.
Inherited from
exportPaths
exportPaths: () =>
Promise<CanvasPath[]>
Defined in: ReactSketchCanvas/types.ts:171
Export the current path data.
Returns
Promise<CanvasPath[]>
Promise that resolves with the current path list.
Remarks
The returned paths can be stored and later passed to loadPaths().
exportSvg
exportSvg: () =>
Promise<string>
Defined in: Canvas/types.ts:256
Export the current canvas as SVG markup.
Returns
Promise<string>
Promise that resolves to SVG markup.
Remarks
The returned string contains the cloned SVG element after export-specific background handling has been applied.
Inherited from
getSketchingTime
getSketchingTime: () =>
Promise<number>
Defined in: ReactSketchCanvas/types.ts:192
Get the total active drawing time in milliseconds.
Returns
Promise<number>
Promise that resolves with the total sketching time.
Remarks
This only works when withTimestamp is enabled before drawing. Idle time
between strokes is not included.
loadPaths
loadPaths: (
paths) =>void
Defined in: ReactSketchCanvas/types.ts:182
Append paths to the canvas.
Parameters
paths
Paths to append to the current drawing.
Returns
void
Nothing.
Remarks
Existing paths are preserved. The provided paths are appended to the end of the current path list and become part of undo/redo history.
redo
redo: () =>
void
Defined in: ReactSketchCanvas/types.ts:162
Restore the next history entry after an undo.
Returns
void
Nothing.
Remarks
Calling redo() when there is no later history entry leaves the canvas
unchanged.
resetCanvas
resetCanvas: () =>
void
Defined in: ReactSketchCanvas/types.ts:202
Remove all paths and clear undo/redo history.
Returns
void
Nothing.
Remarks
Use clearCanvas() instead when the user should be able to undo the
clearing action.
undo
undo: () =>
void
Defined in: ReactSketchCanvas/types.ts:152
Restore the previous history entry.
Returns
void
Nothing.
Remarks
Calling undo() when there is no earlier history entry leaves the canvas
unchanged.