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

react-box

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-box - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

58

box.js

@@ -9,13 +9,21 @@ var React = require('react');

return {
cache: []
cache: [],
hash: generateHashFunction(this.props.hashFunction)
};
},
getDefaultProps: function() {
return {
hashFunction: function(child) {
return JSON.stringify({
key: child.key,
props: child.props
});
}
};
},
componentDidMount: function() {
this.readChildren(this.props.children);
},
componentWillReceiveProps: function(p) {
var cache = this.state.cache;
React.Children.forEach(p.children, function(child) {
cache[signature(child)] = child;
});
this.setState({ cache: cache });
this.readChildren(p.children);
},

@@ -30,6 +38,15 @@ render: function() {

},
readChildren: function(children) {
var cache = this.state.cache;
React.Children.forEach(children, function(child) {
cache[this.state.hash(child)] = child;
}, this);
this.setState({ cache: cache });
},
visibility: function(key) {
var c = React.Children.map(this.props.children, function(child) {
return key === signature(child);
});
return key === this.state.hash(child);
}, this);

@@ -40,16 +57,15 @@ return c ? values(c).some(isTrue) : false;

var ref = {};
var index = 0;
function generateHashFunction(hashFunction) {
var ref = {};
var index = 0;
function signature(child) {
var key = JSON.stringify({
key: child.key,
props: child.props
});
return function(child) {
var key = hashFunction(child);
if (!ref[key]) {
ref[key] = String(++index);
}
if (!ref[key]) {
ref[key] = String(++index);
}
return ref[key];
return ref[key];
};
}

@@ -56,0 +72,0 @@

{
"name": "react-box",
"version": "1.0.0",
"version": "1.0.1",
"description": "Wraps repeatedly rerendered components preserving their nodes in real DOM to reduce paints",

@@ -5,0 +5,0 @@ "main": "box.js",

Sorry, the diff of this file is not supported yet

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