Skip to content

Commit

Permalink
feat(recipe): load recipe data every time
Browse files Browse the repository at this point in the history
  • Loading branch information
stantanasi committed Aug 31, 2024
1 parent 74f97fa commit 6ccc79d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions screens/recipe/RecipeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function RecipeScreen({ navigation, route }: Props) {
const [isDeleting, setIsDeleting] = useState(false)

useEffect(() => {
const fetchRecipe = async () => {
const unsubscribe = navigation.addListener('focus', async () => {
const recipe = await RecipeModel.findById(route.params.id)
.populate<{ author: Model<IUser> }>('author')

Expand All @@ -38,10 +38,10 @@ export default function RecipeScreen({ navigation, route }: Props) {

setRecipe(recipe)
setServings(recipe.servings)
}
})

fetchRecipe()
}, [route.params.id])
return unsubscribe
}, [navigation, route.params.id])

if (!recipe) {
return (
Expand Down

0 comments on commit 6ccc79d

Please sign in to comment.