Add the following useEffect hook
Fri Aug 23 2024 17:22:28 GMT+0000 (Coordinated Universal Time)
Saved by
@negner
useEffect(() => {
if (inputValue) {
const query = `query($code: ID!) {
continent(code: $code) {
countries {
name
}
}
}`;
fetchGraphQL(query, { code: inputValue }).then((data) => {
setCountries(data.data.continent.countries);
});
setIsVisible(true);
const timer = setTimeout(() => {
setIsVisible(false);
}, 1000);
return () => clearTimeout(timer);
}
}, [inputValue]);
content_copyCOPY
Comments