我有这样的问题,将我的React应用程序部署到GitHub后,它只能在我的PC上运行。当我打开链接时,必须使用PC或LapTop link在哪里部署我的应用程序-它可以工作,但是当我尝试通过电话打开它或将此链接发送给我的朋友时-会出现空白页(背景)。那么如何解决这个问题呢?
有我的存储库link
我的package.json的代码
{
"name": "worktests",
"version": "0.1.0",
"private": true,
"homepage": "https://dmitriykulikovskiy.github.io/MyWeatherForecast",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.0",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"font-awesome": "^4.7.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"shortid": "^2.2.15"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"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": {
"gh-pages": "^2.2.0",
"node-sass": "^4.14.1",
"sass-loader": "^8.0.2"
}
}
答案 0 :(得分:1)
问题是这个line:
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
在store.jsx
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
仅在浏览器上安装了Redux Web Tools时可用。您的应用也没有在本地为我运行。但是,一旦安装了扩展程序,它就可以在本地以及已部署的站点上正确运行。
This线程可能有助于找到在生产中使用composeEnhancers
的正确方法。理想情况下,在生产中,您不应依赖开发工具插件填充的属性进行调试,而应直接从compose
使用redux
。