Skip to content

Commit 3fff228

Browse files
author
Ivan Uzun
committed
fix async single mode value render
1 parent 0051369 commit 3fff228

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-sm-select",
3-
"version": "0.4.8",
3+
"version": "0.4.9",
44
"description": "React Multi/Single Select Component",
55
"main": "./dist/index.js",
66
"module": "./es/index.js",

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ export class MultiSelect extends React.Component {
7777
const {props: {value, options, isLoading}, is} = this;
7878
const loadingStart = !prev.isLoading && isLoading;
7979
const loadingEnd = prev.isLoading && !isLoading;
80+
const optionsChanges = prev.options.length !== options.length;
8081
const clearCurrValue = loadingStart ? value : omitDirtyValues(options, value, is('single'));
8182
const clearPrevValue = loadingStart ? prev.value : omitDirtyValues(options, prev.value, is('single'));
82-
if (!areArraysEqual(clearPrevValue, clearCurrValue) || loadingStart || loadingEnd) this.setState({value})
83+
if (!areArraysEqual(clearPrevValue, clearCurrValue) || loadingStart || loadingEnd || optionsChanges) this.setState({value: clearCurrValue})
8384
}
8485

8586
onTagRemove = (index, event) => {

0 commit comments

Comments
 (0)