Skip to main content

api.intercept()

Description

Allows intercepting and blocking/modifying actions

Usage

api.intercept(
action: string,
callback: function
): void;

Parameters

  • action - (required) an action to be fired
  • callback - (required) a callback to be performed (the callback arguments will depend on the action to be fired)
info

The full list of actions can be found here. Use the api.on() method if you want to listen to the actions without modifying them. To make changes to the actions, apply the api.intercept() method.

Example

In the example below we use api.intercept() to hide the default Editor by returning false.

import { useEffect, useRef } from "react";
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
import "wx-react-gantt/dist/gantt.css";

const MyComponent = () => {
const data = getData();
const apiRef = useRef();

useEffect(() => {
if (apiRef.current) {
apiRef.current.intercept("show-editor", (data) => {
return false;
});
}
}, [apiRef.current]);

return <Gantt apiRef={apiRef} tasks={data.tasks} />;
};

export default MyComponent;

Related articles: