facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.91k stars 24.3k forks source link

Use WKWebView instead of UIWebView #321

Closed ckknight closed 6 years ago

ckknight commented 9 years ago

It would be nice if there were a way to use WKWebView instead of UIWebView when using the <WebView> component, as WKWebView has substantial performance benefits.

brunolemos commented 6 years ago

While WebView be the "official way to do it", that's what 99% of developers will use. IMO it doesn't necessarily need to be merged, a note in the docs like it was made with react-navigation could be enough. But merged in the core passes more confidence that it will be maintained.

insraq commented 6 years ago

Maintainer of react-native-wkwebview here. I agree that there are limited benefits for this repo to be merged into core, one of them being Expo support (Expo still uses UIWebView). But I think this is more of an issue for Expo, rather than React Native.

IMO, React Native should focus on the "core" bridges and this component should happily live as a 3rd party component. This makes it easier for people to actually contribute to this project. Also, it means flexible release schedule (as opposed to the monthly release schedule of React Native)

And I agree with @brunolemos that improving React Native docs is a better way to make people more aware of the decision regarding UIWebView and WKWebView and point them to the solution.

fungilation commented 6 years ago

Could react-native-wkwebview be "linked" in RN proper (in documentation if not in code, though being built-in without install would be nicer), as a new WebViewiOS in RN? Then there's no downside even for "touching" existing WebView.

More people see and choose to adopt WebViewiOS, less issues against existing WebView over time until if or when it gets deprecated.

EDIT: as @bowerman0 says below, visibility is a big issue. WebViewiOS in docs allows visibility without breaking existing WebView, and WebViewiOS should state benefits and the fact it uses WKWebView. (for better or worse, largely better)

bowerman0 commented 6 years ago

@hramos The WebView should either be updated to WKWebView or move out of the react-native package. (Both are equally ok with me, personally.) The UIWebView-based WebView can cause unexpected problems for developers that use it. Because the official docs use WebView, most developers probably do not look for alternatives until they encounter problems.

iainbeeston commented 6 years ago

UIWebView is officially deprecated in iOS 12 (I don't think it was in iOS 11, but forgive me if I'm wrong about that) https://developer.apple.com/documentation/uikit/uiwebview

fungilation commented 6 years ago

Good riddance. Get with the times and migrate to WKWebView.

amloelxer commented 6 years ago

@hramos any word on if there are going to be instructions on building on iOS from source anytime soon? I would love to poke around on this and other issues, but as I believe we discussed before, the only instructions to build from source are for Android and they are here https://facebook.github.io/react-native/docs/building-from-source.html. Am I missing something? Are there any guides for building from source for iOS?

amloelxer commented 6 years ago

Also/ or if someone could explain it to me, I would be happy to make a PR to the docs

ckknight commented 6 years ago

I opened this issue over 3 years ago. The lack of action on it has once again blocked a major feature.

smathson commented 6 years ago

@ckknight If lack of action is blocking a major feature for you, consider using https://github.com/CRAlpha/react-native-wkwebview. We are using it in production with no problems.

kelset commented 6 years ago

👋 related to this whole WebView topic, just wanted to let you know that "something is moving": within the core we decided to try an planning an "extraction" of this component into its own separate repo for easier maintenance.

You can follow along and give feedback here: https://github.com/react-native-community/discussions-and-proposals/pull/3

jamonholmgren commented 6 years ago

Because https://github.com/react-native-community/react-native-webview uses WKWebView by default, I'm not planning to migrate this issue over there. This issue can probably be closed.

kelset commented 6 years ago

Sounds good to me - closing

luisnaranjo733 commented 6 years ago

Should we consider WebView to be officially deprecated from RN and migrated to react-native-community?

kelset commented 6 years ago

Basically, yes. It will be properly announced when 0.57.0 is released but yeah, that's what will happen.