Skip to content

Commit 469339b

Browse files
soleh45soleh2
andauthored
fix: clear dropdown on unmount (#114)
* fix: when the user opens the content dropdown then the user immediately unmounts the component, the content is not reset so an error occurs, because the content is not reset and is on another thread * fix: delete double comma --------- Co-authored-by: soleh setiawan <[email protected]>
1 parent 11101ee commit 469339b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ export const AutocompleteDropdown = memo(
6565
LogBox.ignoreLogs(['VirtualizedLists should never be nested'])
6666
}, [])
6767

68+
useEffect(() => {
69+
// Do content cleaning when the component is unmounted
70+
return () => {
71+
setContent(undefined)
72+
};
73+
}, []);
74+
6875
/** Set initial value */
6976
useEffect(() => {
7077
if (!Array.isArray(dataSet) || selectedItem) {

0 commit comments

Comments
 (0)