react-router中getUserConfirmation是在哪里实现的呢?

在看react-router源码的时候,看到了Prompt的实现方法。
然后想起来Prompt可以自定义行为,然后在react-router-dom包里搜了一下getUserConfirmation props。但是我没有找到相关的实现代码

只是在md文档里写了默认使用window.comfirm()。问下各位大神 关于getUserConfirmation的具体实现在哪里呀?

react-router version: 5.2.0

react-router-dom version: 5.2.0

阅读 3.1k
1 个回答
class BrowserRouter extends React.Component {
  history = createHistory(this.props);

  render() {
    return <Router history={this.history} children={this.props.children} />;
  }
}

BrowserRouter 只是简单返回了 Router 组件,那么 this.props 里的 getUserConfirmation 只能是给 createHistory 处理了。 react-router 依赖的 history 版本是 4.9.0 而非最新的 5.0.0 代码。找到 history 中的 createBrowserHistory 方法:https://github.com/ReactTrain...

搜索到对 getUserConfirmation 的使用:https://github.com/ReactTrain...

再深入 createTransitionManager 代码
https://github.com/ReactTrain...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题