使用react-hot-loader 3与自己的服务器
我能够设置react-hot-loader
来正确地绑定我的客户端js,并将更改推送到浏览器并在那里应用(除了[react-router] You cannot change <Router routes>; it will be ignored
警告)。 我使用自己的服务器与koa
, koa-webpack-dev-middleware
和koa-webpack-hot-middleware
,处理webpack和hot。 它也处理我的应用程序与此代码的服务器呈现
export default function *renderReact() { const history = createMemoryHistory(); const store = makeStore(history); const [redirectLocation, renderProps] = yield match.bind(null, { routes, location: this.url, history }); if (redirectLocation) { return this.redirect(redirectLocation.pathname + redirectLocation.search) } if (renderProps == null) { return this.throw(404, 'Not found') } const rootElement = ( <Provider store={store} key="provider"> <RouterContext {...renderProps} /> </Provider> ); this.body = renderApp({ html: yield store.renderToString(ReactDOMServer, rootElement), state: JSON.stringify(store.getState()) }); }
问题是与我的服务器端代码: hot
只适用于客户端代码和更新dynamic更新,但我的服务器代码不会更新作为脚本加载在服务器启动和页面刷新我得不到更新呈现的页面服务器,然后用新的客户端代码进行更新。 并反应警告Warning: React attempted to reuse markup in a container but the checksum was invalid...
问题是:如何处理与服务器上的服务器渲染部分相关的代码更改不重新启动应用程序,因为它打破了热负载?