3
webpack-dev-middlewareに問題がありますが、反応なしステートレス関数を使用してホットリロードするのではなく、クラス拡張コンポーネントを作成するとうまく動作します。Webpack Hot Module ReloaderがReact Statelessコンポーネントで動作しない
たとえば、これは完全に機能します。
// home.js
import React from 'react'
export default class Home extends React.Component {
render() {
return (
<div>
<h1>Drop it like it's hot</h1>
</div>
)
}
}
しかし、これは悲惨に失敗します。
// home.js
import React from 'react'
export default function Home() {
return (
<div>
<h1>Hello World</h1>
</div>
)
}
エラー:それはまだ関連していると人々はまだ問題がある場合は
[Warning] [HMR] The following modules couldn't be hot updated: (Full reload needed) (bundle.js, line 1742)
This is usually because the modules which have changed (and their parents) do not know how to hot reload themselves. See http://webpack.github.io/docs/hot-module-replacement-with-webpack.html for more details.
[Warning] [HMR] - ./client/components/home.js (bundle.js, line 1750)
https://github.com/gaearon/babel-plugin-react-transform/issues/57 – azium
AFAIKは単なる関数なので、反応成分か関数かを静的に判断するのは難しい上記の問題に言及しています) –
これはうまくいかず、プロジェクトのREADMEに記載されています。 – aarosil