Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Jul 9, 2024
1 parent 1547f4f commit 1fd5d26
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
34 changes: 17 additions & 17 deletions packages/frontend/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,23 +425,23 @@ export default function Logs() {
[columnsTouched, checks, view],
)

useTraceUpdate({
projectId,
serializedChecks,
type,
checks,
query,
viewId,
selectedRunId,
allColumns,
evaluators,
visibleColumns,
showSaveView,
logs,
loading,
validating,
runLoading,
})
// useTraceUpdate({
// projectId,
// serializedChecks,
// type,
// checks,
// query,
// viewId,
// selectedRunId,
// allColumns,
// evaluators,
// visibleColumns,
// showSaveView,
// logs,
// loading,
// validating,
// runLoading,
// })

return (
<Empty
Expand Down
37 changes: 19 additions & 18 deletions packages/frontend/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ export function useGlobalShortcut(shortcuts: Shortcut[]) {
}, [shortcuts])
}

export function useTraceUpdate(props: any) {
const prev = useRef(props)
useEffect(() => {
const changedProps = Object.entries(props).reduce(
(lookup, [key, value]) => {
if (prev.current[key] !== value) {
lookup[key] = [prev.current[key], value]
}
return lookup
},
{},
)
if (Object.keys(changedProps).length > 0) {
console.log("Changed props:", changedProps)
}
prev.current = props
})
}
// This helps to debug why a component is re-rendered
// export function useTraceUpdate(props: any) {
// const prev = useRef(props)
// useEffect(() => {
// const changedProps = Object.entries(props).reduce(
// (lookup, [key, value]) => {
// if (prev.current[key] !== value) {
// lookup[key] = [prev.current[key], value]
// }
// return lookup
// },
// {},
// )
// if (Object.keys(changedProps).length > 0) {
// console.log("Changed props:", changedProps)
// }
// prev.current = props
// })
// }

/**
* Custom hook to manage project ID storage.
Expand Down

0 comments on commit 1fd5d26

Please sign in to comment.