Skip to main content

undo

The functionality is available in PRO Edition only

PRO

Description

Allows performing steps back in history

It's required to enable the undo property to perfrom the action.

Actions that can be undone: add-task, update-task, add-link, update-link, delete-task, delete-link, move-task, copy-task.

Hot key for the action: CTRL + Z

Usage

"undo": () => void;

Parameters

The callback of the action takes no parameters.

Example

We enable the undo action on a button click.

import { useRef } from "react";
import { Gantt } from "@svar/react-gantt";
import { Button } from "@svar-ui/react-core";
import { getData } from "../data";

export default function Example() {
const { tasks, links } = getData();
const apiRef = useRef(null);

function undo() {
apiRef.current?.exec("undo");
}

return (
<>
<Button onClick={undo}>Undo</Button>
<Gantt ref={apiRef} tasks={tasks} links={links} undo />
</>
);
}

Related articles: