diff --git a/screens/moves/MoveListScreen.tsx b/screens/moves/MoveListScreen.tsx index e154a39..0b5fd31 100644 --- a/screens/moves/MoveListScreen.tsx +++ b/screens/moves/MoveListScreen.tsx @@ -1,6 +1,6 @@ // screens/moves/MoveListScreen.tsx -import React, { useEffect } from 'react'; +import React from 'react'; import { Button, FlatList, ScrollView, StyleSheet, View } from 'react-native'; import { StackNavigationProp } from '@react-navigation/stack'; import { RootStackParamList } from "../../navigation/navigationTypes"; @@ -10,7 +10,7 @@ import { MoveState } from "../../redux/redu import { AppDispatch } from "../../redux/store"; import MoveListItem from "../../components/MoveListItem"; import { MOVE_DETAIL, MOVE_FORM, MOVE_LIST } from "../../navigation/constants"; -import { RouteProp } from "@react-navigation/native"; +import { RouteProp, useFocusEffect } from "@react-navigation/native"; type MoveListScreenNavigationProp = StackNavigationProp; type MoveListScreenRouteProp = RouteProp; @@ -27,12 +27,14 @@ const MoveListScreen = ({ navigation }: Props) => { const dispatch: AppDispatch = useDispatch(); const moves = useSelector((state: RootState) => state.move.moves); - useEffect(() => { - const loadMoves = async () => { - await (dispatch as AppDispatch)(getMoves()); - }; - loadMoves(); - }, [dispatch, moves]); + useFocusEffect( + React.useCallback(() => { + const loadMoves = async () => { + await (dispatch as AppDispatch)(getMoves()); + }; + loadMoves(); + }, [dispatch]) + ); return ( @@ -48,7 +50,11 @@ const MoveListScreen = ({ navigation }: Props) => { />