backup trace update

This commit is contained in:
2023-10-06 02:38:15 +05:30
parent 329229a21f
commit 5ddb4d48d8
2 changed files with 19 additions and 1 deletions

View File

@@ -16,7 +16,6 @@ RUN npm install
# copy app sources
COPY ./src ./src
COPY tsconfig.json vite.config.ts analyticsrc.json index.html /
RUN echo $(ls)
RUN npm run build
FROM node:16-alpine

View File

@@ -0,0 +1,19 @@
import { useEffect, useRef } from "react"
function useTraceUpdate(props, component) {
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(component + ": Changed props:", changedProps)
}
prev.current = props
})
}
export default useTraceUpdate