UNPKG

wavesurfer-react

Version:
20 lines 680 B
import { useEffect, useRef } from "react"; // TODO: try to merge it with useRegionEvent function useRegionPluginEvent(ref, eventName, callback) { const callbackRef = useRef(null); useEffect(() => { if (!ref) { return; } if (callback) { callbackRef.current = (...args) => callback(...args); ref.on(eventName, callbackRef.current); } return () => { callbackRef.current && ref.un(eventName, callbackRef.current); callbackRef.current = null; }; }, [ref, eventName, callback]); } export default useRegionPluginEvent; //# sourceMappingURL=useRegionPluginEvent.js.map