How To Get Selection Object From React-native Webview
I have an app where I'm using react-native webview to display a document. The user can select some text and perform some custom action that I provide. How do I get the selection ob
Solution 1:
From 0.37.0 onwards there is a new feature in RN that might help you. There is a new prop in the WebView
: onMessage and also a new method, postMessage
that enable two-way communication. From the WebView, you have to call window.postMessage
, and it will invoke the function that you define as callback for onMessage
. You can see a full example in the documentation. As for getting the selected text, check out this answer.
Post a Comment for "How To Get Selection Object From React-native Webview"