我一直在尝试用我的react redux项目来实现redux-persist。这就是我所拥有的。
store.js:
import {compose, createStore, applyMiddleware} from 'redux';
import {persistStore, autoRehydrate} from 'redux-persist';
import {combineReducers} from 'redux';
import thunk from 'redux-thunk';
import reducer f
我想将对象添加到Redux中存在的数组中。如果我不添加redux-persist,代码就可以正常工作,但是在添加redux-persist之后,我得到了一个状态不可迭代的TypeError。我想用redux-persist来运行代码。有没有办法做到这一点? 我的Store代码在添加redux-persist之前: import rootReducer from './reducer';
import {createStore, applyMiddleware} from 'redux';
import thunk from 'redux-thunk
这些configureStore函数和initialState参数之间有什么区别?
import { createStore, applyMiddleware } from 'redux';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import rootReducer from '../reduc
所以redux thunk给了我这个错误(或者不是redux-thunk而是扩展)。
The previous state received by the reducer has unexpected type of "Function".
Expected argument to be an object with the following keys: "register"
商店
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux
有没有办法禁止在一个页面上滚动?我尝试在特定页面上设置overflow: hidden,但没有成功。我必须在index.css的body上设置它,才能使它工作,但这显然会禁用所有页面上的滚动。因此,我想到的唯一方法就是在body上有条件地设置CSS类。有没有办法根据redux存储中的值在index.js中有条件地设置CSS类,或者有没有其他方法? 我的index.js import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter} from 'rea
我的项目出错了。我也没找到解决问题的办法。
这是错误消息:
The previous state received by the reducer has unexpected type of "Function". Expected argument to be an object with the following keys: "posts", "sidebar"
代码:
store.js:
import { createStore, applyMiddleware } from 'redux'
import logger
我不明白为什么需要像redux-thunk这样的东西。据我所知,thunk是一个返回函数的函数。在我看来,包装的表达式和中间件的使用似乎更多地混淆了正在发生的事情。摘自redux-thunk的示例代码
import thunk from 'redux-thunk';
// Note: this API requires redux@>=3.1.0
const store = createStore(
rootReducer,
applyMiddleware(thunk)
);
// Meet thunks.
// A thunk is a function
我最近开始研究redux的部分。据我理解,它应该用于处理异步操作,或者需要从其他操作中分派操作。因此,我已经配置了我的商店,例如:
import {applyMiddleware, createStore} from "redux";
import rootReducer from "./rootReducer";
import thunk from "redux-thunk";
import { composeWithDevTools } from 'redux-devtools-extension'; // used by r