Get how much of a page has loaded in WebView component in React Native - react-native

Is it possible to know how much of a web-page has loaded in a React Native WebView component? I want to show a loading progress for a page loading in my WebView.

Unfortunately there isn't an easy way to do what you ask with the react native web view, you need to implement a fake progress bar yourself.
However, you can use the react native wkwebview component (https://github.com/CRAlpha/react-native-wkwebview) that offers a handy onProgress method:
<WKWebView onProgress={(progress) => console.log(progress)} />
Note that this onProgress method only works on iOs.
I personally prefer using this component instead of the react native web view as it feels much faster and offers more useful methods.

Related

Need to create a toggle component using switch which can be reused

I want to create a Toggle component but it should be created in such a way that it can be used in various modules, please let me know how can I do this.
Plenty of ways to do so. You can use ready modules like react native paper or react native switch or if you want your own implementation you can use react native gesture handler and handle clicks and gestures on your own with a couple of views.

Preferred React Native navigation library

I'm looking for a navigation library for a new React Native project. I've read information on this 3 main libraries:
react-native-router-flux
react-native-navigation
"Standard" react native navigation system
I have read that the "standard" system is very buggy, is it true?
What is your favorite navigation library to date?
The most used navigation library for react is react-navigation as it is kind of simple to use, has a lot of features and can be customise at will.
react-native-router-flux is a wrapper over react-navigation, it is really simple to use and allows you to write a lot less code than with react-navigation, however if you want to implement complex features it might not be the best choice.
react-native-navigation aims to do the same things as react-navigation but... misses the point, as it clearly lakes some complex features that react-navigation has.
I suggest you to read https://medium.com/#ian.mundy/choosing-a-routing-library-for-react-native-604f97e58729 if you can, although that article is from 2017 it is still relevant !
You should give the Navigation router a try. It provides 100% native navigation on iOS and Android. It isn’t like React Native Navigation because it doesn’t require any native setup and has a JavaScript array representation of the native stack of screens.

Is there a way to make React Native custom components without UI?

I am writing a custom component for a Windows 8.1 tablet application our team are mostly developing in React Native.
I've realised that some of the custom code we need doesn't naturally belong to any specific UI element. For example, we want a button to trigger the native Camera UI dialog (as in this CameraUICapture element sample). However, there's no reason this would necessarily be triggered from a button. It could be a callback from something else, it could be a click event on an image. I don't want to lock the function calls to a specific UI piece.
All the tutorials and demos I have managed to find so far for React Custom Components are explicitly for UI pieces, and require implementing a React View manager subclass to interact with React when the piece is loaded. Is this the only way to write native code accessible from a React page? Do I need at least a dummy UI element even to hook into functional code in the native layer, or is there another way?
It turns out the phrase I'm yearning for is "Native Modules".
iOS:
https://facebook.github.io/react-native/docs/native-modules-ios.html
Android:
https://facebook.github.io/react-native/docs/native-modules-android.html
Windows:
https://github.com/Microsoft/react-native-windows/blob/master/docs/NativeModulesWindows.md

cread custom splash / launch screen using an animated svg

I am trying to add an animated SVG as an application loader in a React native app. Their docs don't offer any solution on how I could approach this.
Back when I was working on a react native project, we had used a simple method to achieve splash screen effect.
We had called setTimeout() in componentDidMount() to navigate to the home-screen after 2 seconds. Also, we used to check whether the user is logged-in. If so, we'd navigate straight to the home screen skipping the annoying splash screen altogether.

How to access UINavigationController in react native?

I have created a View where the NavigationBar comes from Obj-c(Native code) and the rest of the view comes from React Native.
Now in the react native view, i have a link which should show the content in a new screen with the navigation experience. I am able to show the content but unable to find a way to change navBar title and show back button on the navBar.
Can you please let me know how we can get access to NavigationBar(Obj-c) in ReactNative?
I don't believe React Native supports this. You cannot take an object created in one language and access it in another. It would be a better idea to create your navigation bar in your JS and use it throughout your app. That even allows you to propagate that UI to your android apps.