我找不到任何问题,在我的代码,似乎都可以。但数据提取是不工作。请帮助我。这里是代码:
商店:
export const store = configureStore({
reducer: {
counter: counterReducer,
profiles:ProfileReducer,
},
});
视图:
const AllUsers = () => {
const { isLoading, error, profiles } = useSelector(state =>state?.profiles)
const dispatch =useDispatch()
useEffect(() => {
dispatch(fetchUsers)
console.log('profiles',profiles);
console.log('error',error);
}, [])
if(isLoading){
return <Loading></Loading>
}
return (
<div>
{profiles && <p>all users{profiles.length}</p>}
</div>
);
};
export default AllUsers;
1条答案
按热度按时间5t7ly7z51#
嗯,找到解决办法了,
我应该将fetchUsers()函数调用回调度函数: