mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 14:06:00 +00:00
grid load fix
This commit is contained in:
17
packages/web/src/utility/usePrevious.js
Normal file
17
packages/web/src/utility/usePrevious.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// copied from https://usehooks.com/usePrevious/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
export default function usePrevious(value) {
|
||||
const ref = React.useRef();
|
||||
|
||||
// Store current value in ref
|
||||
|
||||
React.useEffect(() => {
|
||||
ref.current = value;
|
||||
}, [value]); // Only re-run if value changes
|
||||
|
||||
// Return previous value (happens before update in useEffect above)
|
||||
|
||||
return ref.current;
|
||||
}
|
||||
12
packages/web/src/utility/usePropsCompare.js
Normal file
12
packages/web/src/utility/usePropsCompare.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import _ from 'lodash';
|
||||
import usePrevious from './usePrevious';
|
||||
|
||||
export default function usePropsCompare(props) {
|
||||
const prevProps = usePrevious(props);
|
||||
if (!prevProps) return;
|
||||
for (const key of _.union(_.keys(props), _.keys(prevProps))) {
|
||||
if (props[key] !== prevProps[key]) {
|
||||
console.log(`Different prop value found: prop=${key}, old=${prevProps[key]}, new=${prevProps[key]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user