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

后端 未结 7 1331
有刺的猬
有刺的猬 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:56

    The router actually should never change, so you should be able to just return false for shouldComponentUpdate() in this case.

    import React from 'react'
    import ReactDOM  from 'react-dom'
    import { Router, Route, Link } from 'react-router'
    import App from './index/app'
    import About from './index/about'
    import Inbox from './index/inbox'
    class Routers extends React.Component {
    
      shouldComponentUpdate(){
         return false;
      }
    
      render() {
         return ( 
            <Router>
                <Route path="/" component={App}>
                  <Route path="about" component={About} />
                  <Route path="inbox" component={Inbox} />
                </Route>
            </Router>
          );
        }
    }
    
    0 讨论(0)
提交回复
热议问题