SearchInput: skip state updates after unmount
This commit is contained in:
@@ -15,10 +15,12 @@ const SearchInput: React.FC<SearchInputProps> = () => {
|
|||||||
|
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
let isMounted = true;
|
||||||
if (value !== query) {
|
if (value !== query) {
|
||||||
setValue(query);
|
isMounted && setValue(query);
|
||||||
ReactGA.event({ category: "Search", action: "Tag", label: query });
|
ReactGA.event({ category: "Search", action: "Tag", label: query });
|
||||||
}
|
}
|
||||||
|
return () => void (isMounted = false);
|
||||||
}, [query]);
|
}, [query]);
|
||||||
/* eslint-enable react-hooks/exhaustive-deps */
|
/* eslint-enable react-hooks/exhaustive-deps */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user