【问题标题】:use of ''Getuserconfirmation" in react router v4在反应路由器 v4 中使用“Getuserconfirmation”
【发布时间】:2023-03-12 12:03:01
【问题描述】:

在react router v4中使用''Getuserconfirmation'。它有什么用,有这个和没有这个区别?

const callbacks = (data) => {
  console.log("callback consoled");
}

const getConfirmation = (message, callback) => {
  console.log('heyyy');
const allowTransition = window.confirm(message)
  callbacks(allowTransition)
}

class App extends React.Component {
 render(){
    return(
        <Router getUserConfirmation={getConfirmation}>
        <div>
            <Link exact to = "/">home</Link>
            <Link to = "/men">men</Link>
            <Link to = "/women">women</Link>
        </div>
        </Router>
    );
  }
 }

【问题讨论】:

    标签: javascript reactjs react-router react-redux


    【解决方案1】:

    函数getUserConfirmation 将被路由器调用。

    param 回调是一个 react-router 内部函数,你不需要像回调一样定义它。它的意思是“确认后的下一步行动”。

    函数 getUserConfirmation 必须与 Prompt 一起使用,它没有 when 属性。

    【讨论】:

      猜你喜欢
      • 2017-10-21
      • 2017-12-06
      • 1970-01-01
      • 2018-01-26
      • 2018-08-03
      • 2017-09-16
      • 1970-01-01
      • 1970-01-01
      • 2018-07-07
      相关资源
      最近更新 更多