Error 'Cannot read properties of undefined (reading ‘pushEvent’)' in Custom Visualizations Grafana?

Hi there!
I get the error Cannot read properties of undefined (reading ‘pushEvent’) when I create custom visualizations, please tell me how to fix it.


I get this error when I use the useBlinkingCells custom hook.
Here is a sample code:

import React from 'react';
import { DataFrame, PanelProps } from '@grafana/data';
import { SimpleOptions } from 'types';
import { useBlinkingCells } from 'hooks'; // custom hook
interface Props extends PanelProps<SimpleOptions> {}
export const TablePanel: React.FC<Props> = (props) => {
    ...
   const { blinkingCells } = useBlinkingCells(
    args
   );
    ...
}
export const useBlinkingCells = (
  props
) => {
  const [blinkingCells, setBlinkingCells] = useState({});
  ...
  return {blinkingCells}
}

When I remove the useBlinkingCells custom hook the error goes away, but I need the hook to work. Thank you in advance for your help!

@maxymzakharkiv Please do not open several threads for the same question. One is enough to get the attention of the relevant people in this forum. Opening several repeated questions doesn’t increase your chances of getting an answer.

You already asked about this error here Why am I getting the Cannot read properties of undefined (reading 'pushEvent') error? - #2 by academo