grid load fix

This commit is contained in:
Jan Prochazka
2020-04-03 21:35:24 +02:00
parent aeacc2b170
commit f41383aa08
7 changed files with 49 additions and 12 deletions

View 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;
}

View 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]}`);
}
}
}