Skip to content

Commit

Permalink
chore(docs): Update React Native links to reactnative.dev (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianomlima committed Feb 26, 2020
1 parent 19896fc commit 86c4458
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 72 deletions.
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -65,9 +65,7 @@ import { WebView } from 'react-native-webview';
// ...
class MyWebComponent extends Component {
render() {
return (
<WebView source={{ uri: 'https://facebook.github.io/react-native/' }} />
);
return <WebView source={{ uri: 'https://reactnative.dev/' }} />;
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion bin/setup
Expand Up @@ -18,7 +18,7 @@ fi
# React Native installed?
if ! [ -x "$(command -v react-native)" ]; then
echo 'Error: React Native is not installed.' >&2
echo 'Go here: https://facebook.github.io/react-native/docs/getting-started.html' >&2
echo 'Go here: https://reactnative.dev/docs/getting-started.html' >&2
echo 'Use the "Building Projects With Native Code" option.'
exit 1
fi
Expand Down
28 changes: 14 additions & 14 deletions docs/Custom-Android.md
@@ -1,14 +1,14 @@
While the built-in web view has a lot of features, it is not possible to handle every use-case in React Native. You can, however, extend the web view with native code without forking React Native or duplicating all the existing web view code.

Before you do this, you should be familiar with the concepts in [native UI components](https://facebook.github.io/react-native/docs/native-components-android). You should also familiarise yourself with the [native code for web views](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java), as you will have to use this as a reference when implementing new features—although a deep understanding is not required.
Before you do this, you should be familiar with the concepts in [native UI components](https://reactnative.dev/docs/native-components-android). You should also familiarise yourself with the [native code for web views](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java), as you will have to use this as a reference when implementing new features—although a deep understanding is not required.

## Native Code

To get started, you'll need to create a subclass of `RNCWebViewManager`, `RNCWebView`, and `ReactWebViewClient`. In your view manager, you'll then need to override:

* `createReactWebViewInstance`
* `getName`
* `addEventEmitters`
- `createReactWebViewInstance`
- `getName`
- `addEventEmitters`

```java
@ReactModule(name = CustomWebViewManager.REACT_CLASS)
Expand Down Expand Up @@ -168,30 +168,30 @@ public class CustomWebViewManager extends RNCWebViewManager {

To use your custom web view, you'll need to create a class for it. Your class must:

* Export all the prop types from `WebView.propTypes`
* Return a `WebView` component with the prop `nativeConfig.component` set to your native component (see below)
- Export all the prop types from `WebView.propTypes`
- Return a `WebView` component with the prop `nativeConfig.component` set to your native component (see below)

To get your native component, you must use `requireNativeComponent`: the same as for regular custom components. However, you must pass in an extra third argument, `WebView.extraNativeComponentConfig`. This third argument contains prop types that are only required for native code.

```javascript
import React, {Component, PropTypes} from 'react';
import {requireNativeComponent} from 'react-native';
import {WebView} from 'react-native-webview';
import React, { Component, PropTypes } from 'react';
import { requireNativeComponent } from 'react-native';
import { WebView } from 'react-native-webview';

export default class CustomWebView extends Component {
static propTypes = WebView.propTypes;

render() {
return (
<WebView {...this.props} nativeConfig={{component: RCTCustomWebView}} />
<WebView {...this.props} nativeConfig={{ component: RCTCustomWebView }} />
);
}
}

const RCTCustomWebView = requireNativeComponent(
'RCTCustomWebView',
CustomWebView,
WebView.extraNativeComponentConfig
WebView.extraNativeComponentConfig,
);
```

Expand All @@ -213,8 +213,8 @@ export default class CustomWebView extends Component {
finalUrl: 'about:blank',
};

_onNavigationCompleted = (event) => {
const {onNavigationCompleted} = this.props;
_onNavigationCompleted = event => {
const { onNavigationCompleted } = this.props;
onNavigationCompleted && onNavigationCompleted(event);
};

Expand Down Expand Up @@ -249,6 +249,6 @@ const RCTCustomWebView = requireNativeComponent(
...WebView.extraNativeComponentConfig.nativeOnly,
onScrollToBottom: true,
},
}
},
);
```
15 changes: 9 additions & 6 deletions docs/Getting-Started.md
Expand Up @@ -7,9 +7,11 @@ Here's how to get started quickly with the React Native WebView.
```
$ yarn add react-native-webview
```
(or)

For npm use

(or)

For npm use

```
$ npm install --save react-native-webview
```
Expand All @@ -29,11 +31,12 @@ _NOTE: If you ever need to uninstall React Native WebView, run `react-native unl
### iOS:

If using cocoapods in the `ios/` directory run

```
$ pod install
```

For iOS, while you can manually link the old way using [react-native own tutorial](https://facebook.github.io/react-native/docs/linking-libraries-ios), we find it easier to use cocoapods.
For iOS, while you can manually link the old way using [react-native own tutorial](https://reactnative.dev/docs/linking-libraries-ios), we find it easier to use cocoapods.
If you wish to use cocoapods and haven't set it up yet, please instead refer to [that article](https://engineering.brigad.co/demystifying-react-native-modules-linking-ae6c017a6b4a).

### Android:
Expand All @@ -53,9 +56,9 @@ For Android manual installation, please refer to [this article](https://engineer

### macOS:

Cocoapod and autolinking is not yet support for react-native macOS but is coming soon. In the meantime you must manually link.
Cocoapod and autolinking is not yet support for react-native macOS but is coming soon. In the meantime you must manually link.

The method is nearly identical to the [manual linking method for iOS](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking) except that you will include the `node_modules/react-native-webview/macos/RNCWebView.xcodeproj` project in your main project and link the `RNCWebView-macOS.a` library.
The method is nearly identical to the [manual linking method for iOS](https://reactnative.dev/docs/linking-libraries-ios#manual-linking) except that you will include the `node_modules/react-native-webview/macos/RNCWebView.xcodeproj` project in your main project and link the `RNCWebView-macOS.a` library.

## 3. Import the webview into your component

Expand Down
19 changes: 7 additions & 12 deletions docs/Guide.md
Expand Up @@ -48,9 +48,7 @@ import { WebView } from 'react-native-webview';

class MyWeb extends Component {
render() {
return (
<WebView source={{ uri: 'https://facebook.github.io/react-native/' }} />
);
return <WebView source={{ uri: 'https://reactnative.dev/' }} />;
}
}
```
Expand All @@ -63,13 +61,11 @@ Sometimes you would have bundled an HTML file along with the app and would like
import React, { Component } from 'react';
import { WebView } from 'react-native-webview';

const myHtmlFile = require("./my-asset-folder/local-site.html");
const myHtmlFile = require('./my-asset-folder/local-site.html');

class MyWeb extends Component {
render() {
return (
<WebView source={myHtmlFile} />
);
return <WebView source={myHtmlFile} />;
}
}
```
Expand All @@ -83,7 +79,7 @@ import { WebView } from 'react-native-webview';
class MyWeb extends Component {
render() {
return (
<WebView source={{ uri: "file:///android_asset/local-site.html" }} />
<WebView source={{ uri: 'file:///android_asset/local-site.html' }} />
);
}
}
Expand All @@ -104,7 +100,7 @@ class MyWeb extends Component {
return (
<WebView
ref={ref => (this.webview = ref)}
source={{ uri: 'https://facebook.github.io/react-native/' }}
source={{ uri: 'https://reactnative.dev/' }}
onNavigationStateChange={this.handleWebViewNavigationStateChange}
/>
);
Expand Down Expand Up @@ -141,7 +137,7 @@ class MyWeb extends Component {

// redirect somewhere else
if (url.includes('google.com')) {
const newURL = 'https://facebook.github.io/react-native/';
const newURL = 'https://reactnative.dev/';
const redirectTo = 'window.location = "' + newURL + '"';
this.webview.injectJavaScript(redirectTo);
}
Expand Down Expand Up @@ -195,7 +191,7 @@ Add permission in AndroidManifest.xml:

If the file input indicates that images or video is desired with [`accept`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept), then the WebView will attempt to provide options to the user to use their camera to take a picture or video.

Normally, apps that do not have permission to use the camera can prompt the user to use an external app so that the requesting app has no need for permission. However, Android has made a special exception for this around the camera to reduce confusion for users. If an app *can* request the camera permission because it has been declared, and the user has not granted the permission, it may not fire an intent that would use the camera (`MediaStore.ACTION_IMAGE_CAPTURE` or `MediaStore.ACTION_VIDEO_CAPTURE`). In this scenario, it is up to the developer to request camera permission before a file upload directly using the camera is necessary.
Normally, apps that do not have permission to use the camera can prompt the user to use an external app so that the requesting app has no need for permission. However, Android has made a special exception for this around the camera to reduce confusion for users. If an app _can_ request the camera permission because it has been declared, and the user has not granted the permission, it may not fire an intent that would use the camera (`MediaStore.ACTION_IMAGE_CAPTURE` or `MediaStore.ACTION_VIDEO_CAPTURE`). In this scenario, it is up to the developer to request camera permission before a file upload directly using the camera is necessary.

##### Check for File Upload support, with `static isFileUploadSupported()`

Expand Down Expand Up @@ -304,7 +300,6 @@ _Under the hood_
> On iOS, `injectedJavaScript` runs a method on WebView called `evaluateJavaScript:completionHandler:`
> On Android, `injectedJavaScript` runs a method on the Android WebView called `evaluateJavascriptWithFallback`

#### The `injectedJavaScriptBeforeContentLoaded` prop

This is a script that runs **before** the web page loads for the first time. It only runs once, even if the page is reloaded or navigated away. This is useful if you want to inject anything into the window, localstorage, or document prior to the web code executing.
Expand Down
4 changes: 1 addition & 3 deletions docs/README.portuguese.md
Expand Up @@ -62,9 +62,7 @@ import { WebView } from 'react-native-webview';
// ...
class MyWebComponent extends Component {
render() {
return (
<WebView source={{ uri: 'https://facebook.github.io/react-native/' }} />
);
return <WebView source={{ uri: 'https://reactnative.dev/' }} />;
}
}
```
Expand Down

0 comments on commit 86c4458

Please sign in to comment.