4

我为我的 react/redux 应用程序使用了 react slingshot starter 项目。当我使用类似的路由时,热重载效果很好,/foo但我发现热重载不适用于像/foo/bar. 我没有对开箱即用的 webpack 配置文件进行任何更改,可以在这里找到https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.js

404 GET http://localhost:3004/orders/c344e97ed1fbc2923017.hot-update.json 404 (Not Found)当我有以下路由配置时,我会使用 CreateOrder 组件:

<Route path="/" component={App}>
    <Route path="login" component={Login} />
    <Route path="orders" component={OrderPanel} />
    <Route path="orders/create" component={CreateOrder} />
    <Route path="*" component={NotFoundPage} />
</Route>

但是当我将路径从 orders/create 更改为 just create 时,它​​不会返回 404。

似乎热更新中间件正试图从 /orders 子路由中获取 hot-update.json?

4

2 回答 2

5

只是为了完整性,以及任何对旧版本的弹弓有此问题的人。这在问题 75中也提到过,并通过替换在此处修复:

publicPath: '',

publicPath: '/',

webpack.config.js

更新:根据reduckted 的评论,publicPath 必须以斜线开头和结尾。代替:

publicPath: 'dist/',

publicPath: '/dist/',
于 2016-04-08T11:07:05.047 回答
0

publicPath 配置对我来说不是问题。如果你使用 redux 可以试试这个。

由于某种随机原因redux-devtools,我不允许热重载。尝试从根组件和redux compose配置中删除它。

注意:在您的商店配置中使用带有此配置的 redux devtool 浏览器扩展:window.devToolsExtension ? window.devToolsExtension() : f => f

另外,必须阅读:https ://medium.com/@rajaraodv/webpacks-hmr-react-hot-loader-the-missing-manual-232336dc0d96#.ejpsmve8f

或尝试热重载 3:示例:https ://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915

于 2016-11-25T12:31:32.250 回答