mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 00:06:01 +00:00
query - basic print workflow - messages on client
This commit is contained in:
@@ -16,9 +16,9 @@ export default function useFetch({
|
||||
const [loadCounter, setLoadCounter] = React.useState(0);
|
||||
const socket = useSocket();
|
||||
|
||||
const handleReload = () => {
|
||||
setLoadCounter(loadCounter + 1);
|
||||
};
|
||||
const handleReload = React.useCallback(() => {
|
||||
setLoadCounter((counter) => counter + 1);
|
||||
}, []);
|
||||
|
||||
const indicators = [url, stableStringify(data), stableStringify(params), loadCounter];
|
||||
|
||||
@@ -32,15 +32,29 @@ export default function useFetch({
|
||||
});
|
||||
setValue([resp.data, loadedIndicators]);
|
||||
}
|
||||
|
||||
// React.useEffect(() => {
|
||||
// loadValue(indicators);
|
||||
// if (reloadTrigger && socket) {
|
||||
// socket.on(reloadTrigger, handleReload);
|
||||
// return () => {
|
||||
// socket.off(reloadTrigger, handleReload);
|
||||
// };
|
||||
// }
|
||||
// }, [...indicators, socket]);
|
||||
|
||||
React.useEffect(() => {
|
||||
loadValue(indicators);
|
||||
}, [...indicators]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (reloadTrigger && socket) {
|
||||
socket.on(reloadTrigger, handleReload);
|
||||
return () => {
|
||||
socket.off(reloadTrigger, handleReload);
|
||||
};
|
||||
}
|
||||
}, [...indicators, socket]);
|
||||
}, [socket, reloadTrigger]);
|
||||
|
||||
const [returnValue, loadedIndicators] = value;
|
||||
if (_.isEqual(indicators, loadedIndicators)) return returnValue;
|
||||
|
||||
Reference in New Issue
Block a user