The removeListener event does not take effect

  • Hello, I tried to uninstall the removeListener event, but it doesn't seem to work. The onViewChangecallbacks method still executes,The krpano version used is 1.22.4

    Edited once, last by hushhhhh (July 15, 2025 at 3:47 AM).

  • Please post your full example. The problem must be somewhere else. The removeListener itself is working.

    I have found the reason, because setState in React will cause the onViewChangecallback method to re render, which leads to the failure of calling removeListener to remove listening events. The solution is to use useCallBack to cache the onViewChangecallback method

    Code
    const onViewChangeListener = useCallback(() => {
       console.log('view change')
     }, [kp])

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!