所以我遇到了一个奇怪的问题,当我尝试托管我的网站时,提供商组件不会工作。如果我想使用纱线启动在本地运行它,它可以与提供商一起使用。我很确定我的托管设置是正确的,好像我用jsx组件替换了Provider,它显示了jsx页面。下面是我在App.js文件中的内容。
export default class App extends Component {
render() {
return (
<Provider store={store}>
<AppContainer />
</Provider>
);
}
}
非常感谢任何帮助,谢谢。
这是我的package.json
{
"name": "ca-website",
"version": "0.1.0",
"private": true,
"homepage": "/build",
"dependencies": {
"axios": "^0.17.1",
"material-ui": "^0.20.0",
"raven-js": "^3.20.1",
"react": "^16.2.0",
"react-bootstrap": "^0.31.5",
"react-collapsible": "^2.0.3",
"react-device-detect": "^0.1.0",
"react-dom": "^16.2.0",
"react-ga": "^2.4.1",
"react-google-maps": "^9.4.3",
"react-icons": "^2.2.7",
"react-localization": "^0.1.6",
"react-lottie": "^1.0.0",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.17",
"react-sidebar": "^2.3.2",
"react-tap-event-plugin": "^3.0.2",
"react-typist": "^2.0.4",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-loop": "git+ssh://git@stash.cabforce.com:7999/cod/redux-
loop#cod",
"redux-promise": "^0.5.3",
"redux-storage": "^4.1.2",
"redux-storage-decorator-filter": "^1.1.8",
"redux-storage-decorator-migrate": "^1.1.0",
"redux-storage-engine-localstorage": "^1.1.4",
"redux-thunk": "^2.2.0",
"sweetalert": "^2.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
答案 0 :(得分:0)
管理来解决这个问题,以上所有内容都是正确的,结果证明这是一个ReactRouter问题,我将我的组件包装在BrowserHistory中,将其更改为HashRouter并且瞧它工作正常。这个帖子给了我很多帮助React-router urls don't work when refreshing or writting manually