Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh React Native WebView to initial url?

How does diffing props work for react natives virtual dom(whatever it is called, i.e. yoga)? What is the related source code for it? It might be similar to updateDomProperties(https://holmeshe.me/understanding-react-js-source-code-virtual-dom-diff-VIII/)

Especially, i try to understand react native WebView (https://github.com/react-native-community/react-native-webview) source property. Changing some fictive prop of source forces refreshing of webview for the same uri.

source={{uri:"http://...", forceReload:this.state.forceReload}}

How is this possible especially for Android?

I want to learn this to make sure that this behaviour does not change and break refreshing feature of my webview.

like image 489
subcoder Avatar asked Sep 14 '26 08:09

subcoder


1 Answers

Actually changing some fictive property on source causes virtual dom determine the change and call the setter of the source(setSource()) on the native webview.

But, native webview's setSource() checks uri and does not reload the url.

So, here is my way to refresh web view to initial url;

https://gist.github.com/expressiveco/d0063875ab15631199acc27abf633177

like image 190
subcoder Avatar answered Sep 16 '26 07:09

subcoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!