// screens/moves/MoveListScreen.tsx import React from 'react'; import { Button, FlatList, StyleSheet, View } from 'react-native'; import { StackNavigationProp } from '@react-navigation/stack'; import { RootStackParamList } from "../../navigation/navigationTypes"; import { useDispatch, useSelector } from 'react-redux'; import { deleteMove, getMoves } from '../../redux/actions/moveActions'; import { MoveState } from "../../redux/reducers/moveReducer"; import { AppDispatch } from "../../redux/store"; import MoveListItem from "../../components/MoveListItem"; import { MOVE_DETAIL, MOVE_FORM, MOVE_LIST } from "../../navigation/constants"; import { RouteProp, useFocusEffect } from "@react-navigation/native"; import AlertModal from "../../components/AlertModal"; import { MOVE_ERROR } from "../../redux/constants"; type MoveListScreenNavigationProp = StackNavigationProp; type MoveListScreenRouteProp = RouteProp; type Props = { navigation: MoveListScreenNavigationProp; route: MoveListScreenRouteProp; }; type RootState = { move: MoveState; }; const MoveListScreen = ({ navigation }: Props) => { const error = useSelector((state: RootState) => state.move.error); const dispatch: AppDispatch = useDispatch(); const moves = useSelector((state: RootState) => state.move.moves); useFocusEffect( React.useCallback(() => { const loadMoves = async () => { await (dispatch as AppDispatch)(getMoves()); }; loadMoves(); }, [dispatch]) ); return ( <> dispatch({ type: MOVE_ERROR, payload: null })} /> navigation.navigate(MOVE_FORM, { move: undefined })}/> } renderItem={({ item }) => ( navigation.navigate(MOVE_DETAIL, { move: item })} />