当我尝试更改除布局以外的其他文件时出现错误。更改布局文件时,一切正常,如果尝试更改其他页面'./Pages/Shows'
,请注意,出现错误Warning: You cannot change <Router history>
布局:
import { Router, Switch, Route, Redirect } from 'react-router-dom';
import { hot } from 'react-hot-loader';
import Shows from './Pages/Shows';
const Layout = function ({ startPage, phone }) {
return (
<Provider store={store}>
<Router history={createHistory()}>
<div>
<Header phone={phone}/>
<Switch>
<Route
exact
path="/shows"
component={Shows}
/>
....
const App = hot(module)(Widget);
render(
<App { ...config } />,
document.getElementById('root')
);
我也将插件添加到webpack.config
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: [
'react-hot-loader/webpack',
...