react-render-defender
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -8,2 +8,12 @@ 'use strict'; | ||
var comparePropsAndState = function comparePropsAndState(component, prevProps, prevState) { | ||
var getCustomSettings = function getCustomSettings() { | ||
var customSettings = {}; | ||
try { | ||
customSettings = require(process.env.ROOT + '/rdefender.json'); | ||
} catch (err) {} | ||
return customSettings; | ||
}; | ||
var customSettings = getCustomSettings(); | ||
var propChanges = []; | ||
@@ -38,10 +48,13 @@ var stateChanges = []; | ||
var timeRenderDiff = newRenderTimeStamp - this.previousRenderTimeStamp; | ||
var threshold = this.warningThreshold || 200; | ||
if (timeRenderDiff < threshold) { | ||
var diff = comparePropsAndState(this, prevProps, prevState); | ||
console.groupCollapsed('The component ' + this.constructor.name + ' rendered twice in less than ' + threshold + 'ms!'); | ||
console.info('Time between renders:', timeRenderDiff); | ||
console.info('Props key changes:', diff.propChanges); | ||
console.info('State key changes:', diff.stateChanges); | ||
console.groupEnd(); | ||
var threshold = settings[this.constructor.name] || 200; | ||
if (!settings.quiet_mode) { | ||
if (timeRenderDiff < threshold) { | ||
var diff = comparePropsAndState(this, prevProps, prevState); | ||
console.groupCollapsed('The component ' + this.constructor.name + ' rendered twice in less than ' + threshold + 'ms!'); | ||
console.info('Time between renders:', timeRenderDiff); | ||
console.info('Props key changes:', diff.propChanges); | ||
console.info('State key changes:', diff.stateChanges); | ||
console.groupEnd(); | ||
} | ||
} | ||
@@ -48,0 +61,0 @@ |
@@ -39,3 +39,3 @@ { | ||
}, | ||
"version": "1.0.1" | ||
"version": "1.1.0" | ||
} |
const comparePropsAndState = (component, prevProps, prevState) => { | ||
const getCustomSettings = () => { | ||
let customSettings = {} ; | ||
try { | ||
customSettings = require(process.env.ROOT+'/rdefender.json'); | ||
} catch(err) {} | ||
return customSettings; | ||
} | ||
const customSettings = getCustomSettings(); | ||
const propChanges = []; | ||
@@ -31,10 +41,13 @@ const stateChanges = []; | ||
const timeRenderDiff = newRenderTimeStamp - this.previousRenderTimeStamp; | ||
const threshold = this.warningThreshold || 200 | ||
if (timeRenderDiff < threshold) { | ||
const diff = comparePropsAndState(this, prevProps, prevState); | ||
console.groupCollapsed(`The component ${this.constructor.name} rendered twice in less than ${threshold}ms!`); | ||
console.info('Time between renders:', timeRenderDiff); | ||
console.info('Props key changes:', diff.propChanges); | ||
console.info('State key changes:', diff.stateChanges); | ||
console.groupEnd(); | ||
const threshold = settings[this.constructor.name] || 200 | ||
if(!settings.quiet_mode) { | ||
if (timeRenderDiff < threshold) { | ||
const diff = comparePropsAndState(this, prevProps, prevState); | ||
console.groupCollapsed(`The component ${this.constructor.name} rendered twice in less than ${threshold}ms!`); | ||
console.info('Time between renders:', timeRenderDiff); | ||
console.info('Props key changes:', diff.propChanges); | ||
console.info('State key changes:', diff.stateChanges); | ||
console.groupEnd(); | ||
} | ||
} | ||
@@ -41,0 +54,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5638
5
110
5