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

发布于 2022-09-13 00:42:48 字数 342 浏览 9 评论 0

在看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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天旳寂寞 2022-09-20 00:42:48
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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文