Error: Actions must be plain objects. Instead, the actual type was: 'Promise'. You may need to add middleware

Error: Actions must be plain objects. Instead, the actual type was: 'Promise'. You may need to add middleware

我正在尝试使用 dipatch 获取用户和客户端的列表,但出现此错误: “错误:操作必须是普通对象。相反,实际类型是:'Promise'。您可能需要将中间件添加到商店设置中以处理调度其他值,例如 'redux-thunk' 以处理调度功能。 “

这是我收到错误的代码:

useEffect(() => {
        dispatch(ListClients());
        dispatch(ListUsers());
    }, [dispatch]);

ListClients() 和 ListUsers 的定义是什么?

我很确定您的代码应该如下所示:

useEffect(() => {
    dispatch(ListClients);
    dispatch(ListUsers);
}, [dispatch]);

或者您的函数没有正确的签名。