Advertisement
Guest User

Sisense Line Chart Issue

a guest
Jun 16th, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.82 KB | Source Code | 0 0
  1.  
  2. const containerRef = useRef<HTMLDivElement | null>(null);
  3.  
  4. const TestFunc = useCallback(()=>{
  5.    /*
  6.     whenever deps are chaging, a new instance of TestFunc is generating, which is triggering the use Effect mentioned below, and the new instance is getting appened to the existing subscribed events handlers
  7.     */
  8. },[...deps])
  9.  
  10. useEffect(() => {
  11.     if (widget) {
  12.       widget.destroy();
  13.       widget.initialize();
  14.  
  15.     widget.on('beforequery', TestFunc)
  16.  
  17.     widget?.on('beforeload', () => {
  18.         widgetObject.$$model.$$events.beforequery.handlers = [];
  19.     });
  20.  
  21.       widget.container = containerRef.current;
  22.       widget.refresh();
  23.     }
  24.   }, [widget, TestFunc]);
  25.  
  26.  
  27. return widget ? (
  28.     <div
  29.       data-testid='test-id'
  30.       id='widgetContainerId'
  31.       ref={containerRef}
  32.     />
  33.   ) : null;
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement