MCPcopy Create free account
hub / github.com/GrapesJS/react / useTraceUpdate

Function useTraceUpdate

packages/grapesjs-react/src/utils/index.ts:18–32  ·  view source on GitHub ↗
(props: Record<string, any>)

Source from the content-addressed store, hash-verified

16export function noop() {}
17
18export function useTraceUpdate(props: Record<string, any>) {
19 const prev = useRef(props);
20 useEffect(() => {
21 const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
22 if (prev.current[k] !== v) {
23 (ps as any)[k] = [prev.current[k], v];
24 }
25 return ps;
26 }, {});
27 if (Object.keys(changedProps).length > 0) {
28 console.log('Changed props:', changedProps);
29 }
30 prev.current = props;
31 });
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected