我知道,当您想要异步地分派操作时,像redux thunk这样的解决方案是存在的。然而,最近我遇到了以下情况:
import {store} from "./store";
const initialState = {
todos: []
}
function todoApp(state = initialState, action) {
if(action.type == "ACTION_A"){
// 1. do smth with state
// 2. do smth with state, and then
这些configureStore函数和initialState参数之间有什么区别?
import { createStore, applyMiddleware } from 'redux';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import rootReducer from '../reduc
我将redux-thunk用于异步操作,babel-polyfill用于承诺。我得到以下错误:Error: Actions must be plain objects. Use custom middleware for async actions.
我通过在中间件中包含redux-promise来解决这个问题。我不知道为什么我必须使用redux-promise来解决这个问题,因为Redux中的所有示例都使用babel-polyfill。我是否应该继续使用redux-promise,或者我可能对babel-polyfill有一些问题?
babel-polyfill包含在我的应用程序入口点:
i
react版本为16.13.1。
我想知道在异步方法中使用redux是否有一些好处。
const component = () => {
const asyncFunc = async() => { // <- this part should be moved out to redux-saga?
await callMethod();
}
return (
<div onClick={asyncFunc}>button</div>
)
}
我不知道应该在redux或react组件中调用asyncFunc。
哪个