Archived
removed old hook
This commit is contained in:
1 parent
fe2e58850c
commit
f1e7ad1a27
1 file changed
-21
@@ -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;
|
||||
};
|
||||
Reference in new issue
Block a user