react-route,react-hot-loader.webpack (You cannot change ; it will be ignored)

后端 未结 7 1344
有刺的猬
有刺的猬 2021-02-13 13:16

it\'s my first project that use react,react-router,react-hot-loader,webpack-dev-server and webpack. when I chang

7条回答
  •  后悔当初
    2021-02-13 13:39

    Stormy's suggestion of using worked for me. Here are my warning free code snippits with react hot module replacement:

    ./index.js

    import './globals';
    import React from "react";
    import ReactDOM from "react-dom";
    import { AppContainer as HotContainer } from "react-hot-loader";
    import { browserHistory } from 'react-router';
    import Routes from "./components/Routes.jsx";
    
    const render = function() {
        let Router = require('react-router').Router;
        ReactDOM.render(
            
                
            ,
            document.getElementById('react-container'),
        );
    };
    
    render();
    
    if( module.hot ) {
        module.hot.accept('./components/Routes', () => {
            render();
        });
    }
    

    ./components/Routes.jsx

    import React from "react";
    import { Route, IndexRoute } from "react-router";
    import App from "./App.jsx";
    import Graphs from "./graphs/Graphs.jsx";
    import Trends from "./trends/Trends.jsx";
    import Patterns from "./patterns/Patterns.jsx";
    
    const Routes = (
        
            
            
            
            
        
    );
    export default Routes;
    

提交回复
热议问题