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

uncontrollable

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uncontrollable - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

30

createUncontrollable.js

@@ -63,5 +63,22 @@ 'use strict';

render: function render() {
/**
* If a prop switches from controlled to Uncontrolled
* reset its value to the defaultValue
*/
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var _this = this;
var props = this.props,
keys = Object.keys(controlledValues);
keys.forEach(function (key) {
if (utils.getValue(nextProps, key) === undefined && utils.getValue(props, key) !== undefined) {
_this._values[key] = nextProps[utils.defaultKey(key)];
}
});
},
render: function render() {
var _this2 = this;
var newProps = {};

@@ -76,11 +93,11 @@ var _props = this.props;

var linkPropName = utils.getLinkName(propName),
prop = _this.props[propName];
prop = _this2.props[propName];
if (linkPropName && !isProp(_this.props, propName) && isProp(_this.props, linkPropName)) {
prop = _this.props[linkPropName].value;
if (linkPropName && !isProp(_this2.props, propName) && isProp(_this2.props, linkPropName)) {
prop = _this2.props[linkPropName].value;
}
newProps[propName] = prop !== undefined ? prop : _this._values[propName];
newProps[propName] = prop !== undefined ? prop : _this2._values[propName];
newProps[handle] = setAndNotify.bind(_this, propName);
newProps[handle] = setAndNotify.bind(_this2, propName);
});

@@ -92,2 +109,3 @@

}
}));

@@ -94,0 +112,0 @@

2

index.js

@@ -13,3 +13,3 @@ 'use strict';

shouldComponentUpdate: function shouldComponentUpdate() {
//let the setState trigger the update
//let the forceUpdate trigger the update
return !this._notifying;

@@ -16,0 +16,0 @@ }

{
"name": "uncontrollable",
"version": "3.1.2",
"version": "3.1.3",
"description": "Wrap a controlled react component, to allow spcific prop/handler pairs to be uncontrolled",

@@ -11,3 +11,3 @@ "author": {

"license": "MIT",
"main": "index.js",
"main": "uncontrollable.js",
"keywords": [

@@ -21,8 +21,8 @@ "uncontrolled-component",

],
"peerDependencies": {
"react": ">=0.11.0"
},
"dependencies": {
"invariant": "^2.1.0"
},
"peerDependencies": {
"react": ">=0.11.0 || ^0.14.0-beta3"
}
}
}

@@ -7,2 +7,3 @@ 'use strict';

exports.getType = getType;
exports.getValue = getValue;
exports.getLinkName = getLinkName;

@@ -27,3 +28,3 @@ exports.defaultKey = defaultKey;

return function (props, propName, componentName) {
return function (props, propName) {

@@ -68,2 +69,14 @@ if (props[propName] !== undefined) {

function getValue(props, name) {
var linkPropName = getLinkName(name);
if (linkPropName && !isProp(props, name) && isProp(props, linkPropName)) return props[linkPropName].value;
return props[name];
}
function isProp(props, prop) {
return props[prop] !== undefined;
}
function getLinkName(name) {

@@ -70,0 +83,0 @@ return name === 'value' ? 'valueLink' : name === 'checked' ? 'checkedLink' : null;

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