我的useEffect仅是第一次被调用,后来却没有被调用
import React, { useEffect, useState } from 'react';
import { View, Text, ScrollView } from 'react-native';
import HeaderNavigationBar from '../components/HeaderNavigationBar';
import CustomCard from '../components/CustomCard';
import { useSelector, useDispatch } from 'react-redux'
import * as OrderActions from '../store/actions/order';
export const AccountHistoryScreen = props => {
const orders = useSelector(state => state.orders)
const auth = useSelector(state => state.auth);
const dispatch = useDispatch()
useEffect(()=> {
dispatch(OrderActions.getOrders())
},[dispatch])
return (<View style={{
flex: 1,
flexDirection: 'column',
}}>
<HeaderNavigationBar {...props} />
<View style={{
flex: 1
}}>
<ScrollView>
{orders.result && orders.result.length > 0 && orders.result.map((order, index) =>
<CustomCard key={index} order={order}/>)}
</ScrollView>
{orders.result && orders.result.length === 0 && <View style={{
justifyContent: 'center',
alignItems: 'center',
height: '100%',
}}><Text style={{fontSize: 20}}>No orders Placed Yet</Text></View>}
</View>
</View>);
}
export default AccountHistoryScreen;
这是我的组件,每当我从抽屉式导航器进入此“帐户历史记录”屏幕时,我都想获取订单