Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-render-defender

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-render-defender - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

src/example_of_redefnder.json

29

lib/index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc