Skip to content

Commit 8e71355

Browse files
authored
Merge pull request #23 from BeeInventor/fix/dropdown
fix: dropdown re-render selected item
2 parents 0c209cf + bd66f65 commit 8e71355

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beeinventor/dasiot-react-component-lib",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"module": "lib/index.js",
55
"types": "lib/index.d.ts",
66
"files": [

src/components/Dropdown/Dropdown.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ const Dropdown: React.VFC<DropDownProps> = (props) => {
8282
}
8383
}
8484
}
85-
}, [selectedId, list]);
85+
}, [selectedId]);
86+
87+
useEffect(() => {
88+
for (let i = 0; i < list.length; i++) {
89+
if (selectedId === list[i].id) {
90+
setSelectedItem(list[i]);
91+
break;
92+
}
93+
}
94+
}, [list]);
8695

8796
const handleOnClickSelect = () => {
8897
setIsOpen(true);

0 commit comments

Comments
 (0)