diff --git a/screens/search/SearchScreen.tsx b/screens/search/SearchScreen.tsx index c1bd1d6..0c60aa8 100644 --- a/screens/search/SearchScreen.tsx +++ b/screens/search/SearchScreen.tsx @@ -13,14 +13,14 @@ export default function SearchScreen({ navigation, route }: Props) { const [recipes, setRecipes] = useState[]>([]) useEffect(() => { - const fetchRecipes = async () => { + const unsubscribe = navigation.addListener('focus', async () => { const recipes = await RecipeModel.search(query) setRecipes(recipes) - } + }) - fetchRecipes() - }, [query]) + return unsubscribe + }, [navigation, query]) return (