【发布时间】:2020-05-06 22:12:29
【问题描述】:
我写了一个简单的 React Redux Todo webapp,这是它的GitHub repository;它在我的桌面上运行良好,但是当我将它发布到GitHub pages 时,我得到的只是一个空白页。有趣的是,我在渲染页面元素时添加了一些 console.log 语句,它们显示在控制台上,但它们的页面片段没有。
我使用了Create React App Deployment 页面中的说明,特别是GitHub Pages section 中的说明。
不是homepage属性,predeploy和deploy脚本,下面gh-pages开发依赖是我的package.json文件:
{
"name": "react_todo",
"author": "Rodrigo Silveira",
"version": "0.2.0",
"homepage": "https://rodrigomattososilveira.github.io/react-redux-todo/",
"private": true,
"license": "MIT",
"dependencies": {
"@material-ui/core": "^4.9.11",
"@material-ui/icons": "^4.9.1",
"classnames": "^2.2.6",
"material-table": "^1.57.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"shortid": "^2.2.15",
"typeface-roboto": "^0.0.75"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "yarn run build",
"deploy": "gh-pages -d build",
"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"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.7",
"@types/shortid": "^0.0.29",
"gh-pages": "^2.2.0",
"typescript": "~3.7.2"
}
}
一个
另外请注意,我有一个 React Todo application,我可以使用与 [React Redux Todo(https://github.com/RodrigoMattosoSilveira/react-redux-todo) 表亲完全相同的配方将其发布到它自己的 GitHub Pages。
【问题讨论】:
-
我阅读了这个问题及其两个回复,我似乎都没有帮助。第一个引导我检查由 create-react 创建的 service-worker;我的 react-redux-todo 和 react--todo 应用程序完全相同,process.env.NODE_ENV 测试是看看它是否等于production。第二个建议不相关,因为 react-redux-todo 应用程序没有插入到非 React 应用程序中。谢谢
-
哦,抱歉,我想我将您的问题误读为
React redux tool而不是 todo。
标签: reactjs react-redux github-pages