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

react-select-search

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-select-search - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

33

dist/cjs/useSelect.js

@@ -77,2 +77,25 @@ "use strict";

var updateValue = function updateValue(newValue, optionsList) {
if (newValue === void 0) {
newValue = undefined;
}
if (optionsList === void 0) {
optionsList = flatDefaultOptions;
}
if (newValue === undefined && value) {
return;
}
var option = (0, _getOption["default"])(newValue || defaultValue, optionsList);
if (!option && !allowEmpty) {
var _optionsList = optionsList;
option = _optionsList[0];
}
setValue(option);
};
var onBlur = function onBlur() {

@@ -190,4 +213,4 @@ setFocus(false);

(0, _react.useEffect)(function () {
setValue((0, _getOption["default"])(defaultValue, flatDefaultOptions));
}, [defaultValue, flatDefaultOptions]);
return updateValue(defaultValue);
}, [defaultValue]);
(0, _react.useEffect)(function () {

@@ -197,8 +220,4 @@ var flatOptions = (0, _flattenOptions["default"])(defaultOptions);

setFlatDefaultOptions(flatOptions);
updateValue(undefined, flatOptions);
}, [defaultOptions]);
(0, _react.useEffect)(function () {
if (!value && flatDefaultOptions && !allowEmpty) {
setValue(flatDefaultOptions[0]);
}
}, [flatDefaultOptions, value, allowEmpty]);
return [{

@@ -205,0 +224,0 @@ value: value,

@@ -31,2 +31,16 @@ import { useReducer, useEffect, useMemo, useState, useRef } from 'react';

const updateValue = (newValue = undefined, optionsList = flatDefaultOptions) => {
if (newValue === undefined && value) {
return;
}
let option = getOption(newValue || defaultValue, optionsList);
if (!option && !allowEmpty) {
[option] = optionsList;
}
setValue(option);
};
const onBlur = () => {

@@ -134,15 +148,9 @@ setFocus(false);

};
useEffect(() => updateValue(defaultValue), [defaultValue]);
useEffect(() => {
setValue(getOption(defaultValue, flatDefaultOptions));
}, [defaultValue, flatDefaultOptions]);
useEffect(() => {
const flatOptions = FlattenOptions(defaultOptions);
setOptions(flatOptions);
setFlatDefaultOptions(flatOptions);
updateValue(undefined, flatOptions);
}, [defaultOptions]);
useEffect(() => {
if (!value && flatDefaultOptions && !allowEmpty) {
setValue(flatDefaultOptions[0]);
}
}, [flatDefaultOptions, value, allowEmpty]);
return [{

@@ -149,0 +157,0 @@ value,

{
"name": "react-select-search",
"version": "1.1.5",
"version": "1.1.6",
"description": "Lightweight select component for React",

@@ -5,0 +5,0 @@ "main": "dist/esm/index.js",

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