Skip to content

Commit

Permalink
fix: clear dropdown on unmount (#114)
Browse files Browse the repository at this point in the history
* 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 <soleh.setiawan@legit-group.com>
  • Loading branch information
soleh45 and soleh setiawan authored Mar 17, 2024
1 parent 11101ee commit 469339b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ export const AutocompleteDropdown = memo(
LogBox.ignoreLogs(['VirtualizedLists should never be nested'])
}, [])

useEffect(() => {
// Do content cleaning when the component is unmounted
return () => {
setContent(undefined)
};
}, []);

/** Set initial value */
useEffect(() => {
if (!Array.isArray(dataSet) || selectedItem) {
Expand Down

0 comments on commit 469339b

Please sign in to comment.