我正在努力在现有的大型React项目中连接Next.js和redux-saga。我正在遵循Next.js示例代码。示例代码可以正常工作,但是当我尝试移动Next.js redux-saga示例代码https://github.com/zeit/next.js/tree/master/examples/with-redux-saga时,我的数据没有存储在商店中。我不确定是否要调用我的存储操作,还是晚调用该存储,但最终还是空了存储。
我正在跟踪输出,发现redux-saga任务似乎带有示例代码的done
字段,但是对于我的代码,它具有toPromise
字段。
我在两个项目之间可以看到的唯一明显区别是,示例代码使用redux-saga 0.16.0,而我的项目使用^ 1.0.0。
当我切换项目以使用redux-saga 0.16.0时,它工作正常。
也许这两个项目所依赖的next-redux-saga正在寻找done
字段?可能还有其他吗?我附加了两个package.json字段,以防您发现我没有的东西。谢谢你的帮助!
示例代码package.json
{
"name": "with-redux-saga",
"version": "1.0.0",
"license": "ISC",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"es6-promise": "4.1.1",
"isomorphic-unfetch": "2.0.0",
"next": "^7.0.2",
"next-redux-saga": "3.0.0",
"next-redux-wrapper": "2.0.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "5.0.7",
"redux": "4.0.0",
"redux-saga": "^1.0.0"
},
"devDependencies": {
"redux-devtools-extension": "2.13.2"
}
}
我的package.json
{
"name": "PAW-React",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/InterficieIS/PAW-React.git",
"author": "Javier1177 <javierlopezblasco@gmail.com>",
"license": "MIT",
"dependencies": {
"@date-io/date-fns": "^1.0.1",
"@material-ui/core": "^3.8.3",
"autoprefixer": "7.1.5",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-wrap-in-js": "^1.1.0",
"bulma": "^0.6.2",
"date-fns": "^2.0.0-alpha.27",
"dotenv": "^4.0.0",
"eslint-config-airbnb": "^17.1.0",
"express": "^4.16.4",
"glob": "^7.1.2",
"isomorphic-unfetch": "^3.0.0",
"jss": "^9.8.7",
"material-ui-pickers": "^2.1.1",
"next": "^7.0.2",
"next-fonts": "^0.16.0",
"next-redux-saga": "^3.0.0",
"next-redux-wrapper": "^2.1.0",
"node-sass": "^4.4.0",
"normalize.css": "^7.0.0",
"prop-types": "^15.6.2",
"raw-loader": "^0.5.1",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-jss": "^8.6.1",
"react-redux": "^6.0.0",
"react-slick": "^0.23.2",
"redux": "^4.0.1",
"redux-saga": "^1.0.0",
"sass-loader": "^6.0.6",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"command-line-args": "^4.0.7",
"cross-env": "^5.1.3",
"eslint": "^5.12.0",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.41.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.5.1",
"file-loader": "^3.0.1",
"url-loader": "^1.1.2",
"redux-devtools-extension": "^2.13.7"
},
"scripts": {
"dev": "PORT=3001 node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js",
"export": "next export",
"eslint": "eslint . --ext=\"js,jsx\""
}
}
答案 0 :(得分:1)
react-redux版本1.0.0带来了那些项目中尚未实现的API重大更改。请跟踪以下问题和请求,以了解更多信息:
https://github.com/zeit/next.js/pull/6109
https://github.com/bmealhouse/next-redux-saga/issues/27
https://github.com/bmealhouse/next-redux-saga/pull/29
最好的问候