reactjs - Xamarin ReactJS WebView 导航

标签 reactjs xamarin webview react-router

我正在尝试使用 Xamarin forms webview .Navierated 事件来检测 react 应用程序中页面位置何时发生变化。然而,它似乎只在我导航到外部页面时发出,而不是在 react 应用程序内发出,即使我使用的是 react 路由器。在我的浏览器中,url 发生变化,但 Xamarin webview 不会注册该更改,即使我通过打印 webView.Source 手动轮询 url。

有什么方法可以从 C# 检测 React 应用程序内的导航吗?

最佳答案

如果您希望组件具有位置感知能力,您可以使用 HoC withRouter 包装它。由React Router提供.

You can get access to the history object’s properties and the closest <Route>'s match via the withRouter higher-order component. withRouter will re-render its component every time the route changes with the same props as render props: { match, location, history }.

在 React 应用程序中获取位置更改更新后,您可以更新 C# 以执行您需要的任何操作。

编辑:解决您的评论...

现在我从未使用过 C#,但根据我的研究,这应该可行......看看 __doPostBack 。您可以阅读如何使用它 here .

关于reactjs - Xamarin ReactJS WebView 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45120871/

相关文章:

javascript - 如何在不刷新页面的情况下查看更新的列表

ios - 如何使用nunit控制台指定平台(android或ios)测试

ios - 如何使用自动布局基于 webview 内容管理 UITableHeaderView 的高度

android - 将 Cookies 注入(inject) WebView

android - 将 Facebook SDK session 传递给 webview

javascript - React - 元素类型无效 : expected a string

javascript - ReactJS:如何获取另一个组件的状态属性?

javascript - 如何将 JSON 与 react-ace 一起使用?

ios - Xamarin 和 ios 10 - 所有页面都移到了标题栏后面

c# - 如何使用 Visual Studio 通过 Xamarin UITest 执行 CI