Moss Palmer
Moss Palmer

Reputation: 1854

React Native Access WebView Actions or WebView's ScrollView

I would like to be able to trigger some action a React Native App based on the Scroll events of a WebView e.g. Hide Elements when scrolled one way, return them when scrolled another way.

I have looked at the methods of WebView https://facebook.github.io/react-native/docs/webview.html#content but cannot see anything exposed that would allow me to do this.

I could - as a really poor hack - inject some javascript and get it to set the title to a given value when scrolled and check for this value in the parent component but I'm hoping for a cleaner approach.

Upvotes: 2

Views: 3359

Answers (1)

Colin Ramsay
Colin Ramsay

Reputation: 16466

I think you're basically talking about this:

It would be really great to be able to run JS inside of a WebView component and register event listeners within regular React Native code.

https://github.com/facebook/react-native/issues/586

Fortunately off the back of that, someone's started a project to bridge between the two:

This is an attempt to create a Javascript Bridge between React Native and Webview.

https://github.com/alinz/react-native-webview-bridge

You have to use WebViewBridge instead of WebView but I wouldn't see that as a problem.

Upvotes: 3

Related Questions