react-select-search
Advanced tools
Comparing version 3.0.3 to 3.0.5
@@ -14,3 +14,9 @@ "use strict"; | ||
if (!multiple) { | ||
return (0, _getOption["default"])(value, options) || oldValue; | ||
var newOption = (0, _getOption["default"])(value, options); | ||
if (newOption) { | ||
return newOption; | ||
} | ||
return oldValue; | ||
} | ||
@@ -17,0 +23,0 @@ |
@@ -50,2 +50,3 @@ "use strict"; | ||
var ref = (0, _react.useRef)(null); | ||
var valueRef = (0, _react.useRef)(undefined); | ||
@@ -134,2 +135,7 @@ var _useState = (0, _react.useState)(null), | ||
(0, _react.useEffect)(function () { | ||
if (valueRef.current === defaultValue) { | ||
return; | ||
} | ||
valueRef.current = defaultValue; | ||
setValue((0, _getOptions["default"])(defaultValue, null, options, multiple)); | ||
@@ -136,0 +142,0 @@ }, [defaultValue, multiple, options]); |
@@ -5,3 +5,9 @@ import valueToArray from './valuteToArray'; | ||
if (!multiple) { | ||
return getOption(value, options) || oldValue; | ||
const newOption = getOption(value, options); | ||
if (newOption) { | ||
return newOption; | ||
} | ||
return oldValue; | ||
} | ||
@@ -8,0 +14,0 @@ |
@@ -25,2 +25,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
const ref = useRef(null); | ||
const valueRef = useRef(undefined); | ||
const [value, setValue] = useState(null); | ||
@@ -88,2 +89,7 @@ const [search, setSearch] = useState(''); | ||
useEffect(() => { | ||
if (valueRef.current === defaultValue) { | ||
return; | ||
} | ||
valueRef.current = defaultValue; | ||
setValue(getOptions(defaultValue, null, options, multiple)); | ||
@@ -90,0 +96,0 @@ }, [defaultValue, multiple, options]); |
{ | ||
"name": "react-select-search", | ||
"version": "3.0.3", | ||
"version": "3.0.5", | ||
"description": "Lightweight select component for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/esm/index.js", |
@@ -7,3 +7,3 @@ <p align="center"> | ||
<a href="https://www.npmjs.com/package/react-select-search"> | ||
<img src="https://travis-ci.org/tbleckert/react-select-search.svg?branch=master" style="max-width:100%;" /> | ||
<img src="https://travis-ci.org/tbleckert/react-select-search.svg?branch=main" style="max-width:100%;" /> | ||
</a> | ||
@@ -10,0 +10,0 @@ <a href='https://coveralls.io/github/tbleckert/react-select-search'> |
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
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
80166
1904