api.intercept()
Description
Allows intercepting and blocking/modifying actionsUsage
api.intercept(
action: string,
callback: function
): void;
Parameters
action
- (required) an action to be firedcallback
- (required) a callback to be performed (the callback arguments will depend on the action to be fired)
info
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: