我尝试了redux的所有命令,但都不起作用:您认为解决方案是什么?
yarn add react-redux
yarn add reduxjs / Redux-thunk#master
npm install --save Redux react-redux
npm install redux -- save
npm i redux -- save
yarn add redux-thunk
index.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import {createStore, applyMiddleware,compose} from 'redux';
import rootReducer from './store/reducers/rootReducer';
import {Provider} from 'react-redux';
import thunk from 'redux-thunk';
import {reduxFirestore,getFirestore} from 'redux-firestore'
import {reactReduxFirebase,getFirebase} from 'react-redux-firebase'
import fbConfig from './config/fbConfig';
const store=createStore(rootReducer,
compose(
applyMiddleware(thunk.withExtraArgument({getFirebase,getFirestore})),
reduxFirestore(fbConfig),
reactReduxFirebase(fbConfig)
));
ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
package.json
{
"name": "omaga-yazilim",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^npm i --save react-router4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"firebase": "^7.8.1",
"jest-leak-detector": "^25.1.0",
"moment": "^2.22.2",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-redux": "^7.1.3",
"react-redux-firebase": "^3.1.1",
"react-router": "^4.4.0-beta.8",
"react-router-dom": "^4.4.0-beta.6",
"react-scripts": "^2.1.1",
"redux": "^4.0.5",
"redux-firestore": "^0.12.0",
"redux-thunk": "reduxjs/redux-thunk#master",
"start": "webpack-dev-server --mode development"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
4条答案
按热度按时间wd2eg0qa1#
我遇到了同样的问题,但我运行了命令行:
npm安装--保存还原形实转换
jgzswidk2#
最简单的解决方案是使用our new official Redux Toolkit package。
configureStore
function将自动正确地设置存储,包括默认添加thunk中间件。假设您尝试使用React-Redux-Firebase,您可以通过使用getDefaultMiddleware
API来完成此操作:wyyhbhjk3#
我有一个类似的问题,这是我如何解决它:
停止服务器:在终端中按Ctrl C。
打开package.json并手动添加:
然后在终端cd中进入项目并安装redux thunk:
重新启动服务器:
有关redux形实转换的更多详细信息,请访问以下链接:
ReduxThunk-Github
camsedfj4#
我也有同样的问题...这就是我如何解决它...
停止服务器Ctrl + C
打开包. json
并删除可用的redux-thunk版本,如下所示进行替换...
然后转到终端并使用以下命令安装redux-thunk...
然后启动服务器