// 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"; type MoveListScreenNavigationProp = StackNavigationProp; type MoveListScreenRouteProp = RouteProp; type Props = { navigation: MoveListScreenNavigationProp; route: MoveListScreenRouteProp; }; type RootState = { move: MoveState; }; const MoveListScreen = ({ navigation }: Props) => { 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 ( navigation.navigate(MOVE_FORM, { move: undefined })}/> } renderItem={({ item }) => ( navigation.navigate(MOVE_DETAIL, { move: item })} />