@simbathesailor/use-what-changed
Advanced tools
Comparing version
@@ -7,2 +7,3 @@ 'use strict'; | ||
var what_debug_changed = 0; | ||
/** | ||
@@ -49,15 +50,6 @@ * Taken random color logic from some stackoverflow answer | ||
React.useEffect(function () { | ||
var MyWindow = window; | ||
if (MyWindow) { | ||
if (MyWindow.what_debug_changed) { | ||
MyWindow.what_debug_changed++; | ||
whatChangedHookCountRef.current = MyWindow.what_debug_changed; | ||
} else { | ||
whatChangedHookCountRef.current = 1; | ||
MyWindow.what_debug_changed = 1; | ||
} | ||
backgroundColorRef.current = getRandomColor(); | ||
} | ||
// const MyWindow: IWindow = window; | ||
what_debug_changed++; | ||
whatChangedHookCountRef.current = what_debug_changed; | ||
backgroundColorRef.current = getRandomColor(); | ||
}, []); | ||
@@ -64,0 +56,0 @@ React.useEffect(function () { |
@@ -1,2 +0,2 @@ | ||
"use strict";var e,r=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,t=function(e){return"[object Object]"===Object.prototype.toString.call(e)};function n(e){return t(e)||Array.isArray(e)?JSON.stringify(e,null,2):e}exports.useWhatChanged=function(e,t){var u=r.useRef(e),a=r.useRef(1),c=r.useRef(""),o=Array.isArray(e);r.useEffect((function(){var e=window;e&&(e.what_debug_changed?(e.what_debug_changed++,a.current=e.what_debug_changed):(a.current=1,e.what_debug_changed=1),c.current=function(){for(var e="#",r=0;r<6;r++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return e}())}),[]),r.useEffect((function(){if(e){console.log("%c What Changed in Effect ID "+a.current+" ","background: "+c.current+"; color: white; font-size: 10px","🧐👇");var r=t?t.split(","):null,o=e.reduce((function(e,a,c){if(u.current&&a!==u.current[c]){var o=u.current[c];return u.current[c]=a,t&&r?e[r[c]+' "✅"']={"Old Value":n(o),"New Value":n(a)}:e[c+' "✅"']={"Old Value":n(o),"New Value":n(a)},e}return t&&r?e[r[c]+' "⏺"']={"Old Value":n(a),"New Value":n(a)}:e[c+' "⏺"']={"Old Value":n(a),"New Value":n(a)},e}),{});console.table(o)}}),[].concat(e&&o?e:[],[u]))}; | ||
"use strict";var e,r=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,t=0,u=function(e){return"[object Object]"===Object.prototype.toString.call(e)};function n(e){return u(e)||Array.isArray(e)?JSON.stringify(e,null,2):e}exports.useWhatChanged=function(e,u){var c=r.useRef(e),a=r.useRef(1),o=r.useRef(""),l=Array.isArray(e);r.useEffect((function(){t++,a.current=t,o.current=function(){for(var e="#",r=0;r<6;r++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return e}()}),[]),r.useEffect((function(){if(e){console.log("%c What Changed in Effect ID "+a.current+" ","background: "+o.current+"; color: white; font-size: 10px","🧐👇");var r=u?u.split(","):null,t=e.reduce((function(e,t,a){if(c.current&&t!==c.current[a]){var o=c.current[a];return c.current[a]=t,u&&r?e[r[a]+' "✅"']={"Old Value":n(o),"New Value":n(t)}:e[a+' "✅"']={"Old Value":n(o),"New Value":n(t)},e}return u&&r?e[r[a]+' "⏺"']={"Old Value":n(t),"New Value":n(t)}:e[a+' "⏺"']={"Old Value":n(t),"New Value":n(t)},e}),{});console.table(t)}}),[].concat(e&&l?e:[],[c]))}; | ||
//# sourceMappingURL=use-what-changed.cjs.production.min.js.map |
import React from 'react'; | ||
var what_debug_changed = 0; | ||
/** | ||
@@ -44,15 +45,6 @@ * Taken random color logic from some stackoverflow answer | ||
React.useEffect(function () { | ||
var MyWindow = window; | ||
if (MyWindow) { | ||
if (MyWindow.what_debug_changed) { | ||
MyWindow.what_debug_changed++; | ||
whatChangedHookCountRef.current = MyWindow.what_debug_changed; | ||
} else { | ||
whatChangedHookCountRef.current = 1; | ||
MyWindow.what_debug_changed = 1; | ||
} | ||
backgroundColorRef.current = getRandomColor(); | ||
} | ||
// const MyWindow: IWindow = window; | ||
what_debug_changed++; | ||
whatChangedHookCountRef.current = what_debug_changed; | ||
backgroundColorRef.current = getRandomColor(); | ||
}, []); | ||
@@ -59,0 +51,0 @@ React.useEffect(function () { |
{ | ||
"name": "@simbathesailor/use-what-changed", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "simbathesailor", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34800
-4.43%209
-5.43%