removed old hook

This commit is contained in:
mmacierzanka committed 2021-10-08 18:27:50 +02:00
1 parent fe2e58850c
commit f1e7ad1a27
1 file changed
-21
-21
View File
@@ -1,21 +0,0 @@
import { useEffect, useState } from "react";
import { API_CLIENT } from "../constants";
export const useDbEvents = (callback) => {
if (typeof callback !== "function") throw new TypeError("Invalid callback");
const [componentState, updateComponentState] = useState(API_CLIENT.events);
useEffect(() => {
const listenerFn = (events, data) => {
callback(events, data);
updateComponentState(events);
};
API_CLIENT.on("EVENT_RELOAD", listenerFn);
API_CLIENT.on("EVENT_CREATE", listenerFn);
return () => {
API_CLIENT.removeListener("EVENT_RELOAD", listenerFn);
API_CLIENT.removeListener("EVENT_CREATE", listenerFn);
};
// eslint-disable-next-line
}, []);
return componentState;
};