Every time you switch a route, a prompt pops up asking if you are sure and how to trigger it globally.

question:

this is a code from Ruan Yifeng"s react-router:
address: http://www.ruanyifeng.com/blo. slide to the bottom

how can I put it into the overall situation through this code? Which file should I put in?

my index.js:

import $ from "jquery"
import React from "react"
import ReactDOM from "react-dom"
import AppRouter from "./router"
import { Provider } from "react-redux"
import LocaleProvider from "antd/lib/locale-provider"
import configureStore from "./store"
import "./assets/style/index.less"
import zhCN from "antd/lib/locale-provider/zh_CN";

const store = configureStore();


class Root extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <LocaleProvider locale={zhCN}>
        <Provider store={store}>
          <div>
            <AppRouter store={store} />
          </div>
        </Provider>
      </LocaleProvider>
    )
  }
}
ReactDOM.render(<Root />, document.getElementById("p_app"))


can I put it here?

Jun.07,2021

of course you can put it here.


use high-level components:

import Immutable from "immutable"
import React from "react"
import { withRouter } from "react-router"

const routerLeaveHookHoc = WrappedComponent => {
    //withRouterrouterLeaveHookHoc 
    return withRouter(
        class extends React.Component {
            componentDidMount() {
                console.log("didmount");
                this.props.router.setRouteLeaveHook(
                    this.props.route,
                    this.routeLeaveHook
                );
            }

            routeLeaveHook(a){
              //  false 
              // 
            }
            render() {
                return <WrappedComponent {...this.props}/>
            }
        }
    )
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b22422-2b5e6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b22422-2b5e6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?