Also use PureDatagridRow to speed up SongDatagrid

This commit is contained in:
Deluan
2020-11-27 14:24:22 -05:00
parent f7d1b80b69
commit 90c407b7f6
3 changed files with 21 additions and 3 deletions
+17
View File
@@ -0,0 +1,17 @@
import { useRef, useEffect } from 'react'
export function useTraceUpdate(props) {
const prev = useRef(props)
useEffect(() => {
const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
if (prev.current[k] !== v) {
ps[k] = [prev.current[k], v]
}
return ps
}, {})
if (Object.keys(changedProps).length > 0) {
console.log('Changed props:', changedProps)
}
prev.current = props
})
}