Summary:
Opening a new PR for #10946 (see discussion there).
This PR builds upon #14775 (iOS ViewManager inheritance) and #14261 (more extensible Android WebView).
**Motivation**
When `WebView.android.js` and `WebView.ios.js` use `requireNativeComponent`, they are hard-coded to require `RCTWebView`. This means if you want to re-use the same JS-logic, but require a custom native WebView-implementation, you have to duplicate the entire JS-code files.
The same is true if you want to pass through any custom events or props, which you want to set on the custom native `WebView`.
What I'm trying to solve with this PR is to able to extend native WebView logic, and being able to re-use and extend existing WebView JS-logic.
This is done by adding a new `nativeConfig` prop on WebView. I've also moved the extra `requireNativeComponent` config to `WebView.extraNativeComponentConfig` for easier re-use.
**Test plan**
jacobp100 has been kind enough to help me with docs for this new feature. So that is part of the PR and can be read for some information.
I've also created an example app which demonstrates how to use this functionality: https://github.com/cbrevik/webview-native-config-example
If you've implemented the native side as in the example repo above, it should be fairly easy to use from JavaScript like this:
```javascript
import React, { Component, PropTypes } from 'react';
import { WebView, requireNativeComponent, NativeModules } from 'react-native';
const { CustomWebViewManager } = NativeModules;
export default class CustomWebView extends Component {
static propTypes = {
...WebView.propTypes,
finalUrl: PropTypes.string,
onNavigationCompleted: PropTypes.func,
};
_onNavigationCompleted = (event) => {
const { onNavigationCompleted } = this.props;
onNavigationCompleted && onNavigationCompleted(event);
}
render() {
return (
<WebView
{...this.props}
nativeConfig={{
component: RCTCustomWebView,
props: {
finalUrl: this.props.finalUrl,
onNavigationCompleted: this._onNavigationCompleted,
},
viewManager: CustomWebViewManager
}}
/>
);
}
}
const RCTCustomWebView = requireNativeComponent(
'RCTCustomWebView',
CustomWebView,
WebView.extraNativeComponentConfig
);
```
As you see, you require the custom native implementation at the bottom, and send in that along with any custom props with the `nativeConfig` prop on the `WebView`. You also send in the `viewManager` since iOS requires that for `startLoadWithResult`.
**Discussion**
As noted in the original PR, this could in principle be done with more React Native components, to make it easier for the community to re-use and extend native components.
Closes https://github.com/facebook/react-native/pull/15016
Differential Revision: D5701280
Pulled By: hramos
fbshipit-source-id: 6c3702654339b037ee81d190c623b8857550e972
Summary:
Minor documentation correction for the native components iOS API section.
Before: "Sometimes your native component will have some special properties that you don't want to them to be part of the API"
After: "Sometimes your native component will have some special properties that you don't want to be part of the API"
Confirm section renders correctly via markdown.
Closes https://github.com/facebook/react-native/pull/15914
Reviewed By: TheSavior
Differential Revision: D5817146
Pulled By: buymeasoda
fbshipit-source-id: 075441cf7f5f23a4ca512bae48ca8fc319762b1e
Summary:
Hopefully, this will save an hour of WTFs for the next reader.
Closes https://github.com/facebook/react-native/pull/14876
Differential Revision: D5385881
Pulled By: hramos
fbshipit-source-id: 56961e8a5eb3b6fae4f92c7fb9fea1e1147a3521
Summary:
Follow up on https://github.com/facebook/react-native/issues/14436
hramos:
> MapViewIOS was removed a couple of versions ago. No one has touched this guide in a while, so unless someone volunteers to get it back up to date, we'll probably end up removing it from the docs.
I'm volunteering to get it back up to date!
- Fixed broken code examples
- Swapped out `pitchEnabled` for `zoomEnabled`, needs less explaining and it's easier to test on a simulator.
- Renamed RNTMap to RNTMapView for clarity.
- Renamed inconsistent `onChange`s to onRegionChange`.
- Swapped out 'vending' for 'exposing'.
I wasn't really sure about the last 3 points. I think it's more clear like this, but please review.
I'll add some review comments as well.
Closes https://github.com/facebook/react-native/pull/14991
Differential Revision: D5416319
Pulled By: hramos
fbshipit-source-id: bc70942a66acc5e3967b245af8271a1d2465ab60
Summary:
react@16 (a peerDependency) did away with the PropTypes export in favor of the prop-types module.
This updates all of the remaining references to `React.PropTypes`.
Closes https://github.com/facebook/react-native/pull/14641
Differential Revision: D5287167
Pulled By: javache
fbshipit-source-id: a917e29aa0e5470260568995dfe97f5528ec265e
Summary:
The current website defaults to using JavaScript for any code block, regardless of language tag. This PR adds syntax highlighting support by passing the necessary language prop and by adding any missing languages to Marked.js.
Depends on #14212, #14065
Closes https://github.com/facebook/react-native/pull/14215
Differential Revision: D5149897
Pulled By: hramos
fbshipit-source-id: 95a817af2168d5743c75dd1ac030d399a68fb93c
Summary:
We've noticed that many newcomers paste sample code straight into a project created using `react-native init AwesomeProject`, but the sample code assumes the user is creating a new project for each example. This PR makes it so that these samples can be pasted into the same project from the Getting Started.
Closes https://github.com/facebook/react-native/pull/14264
Differential Revision: D5149746
Pulled By: hramos
fbshipit-source-id: cae95ab5b7baf64ddd9fe12d342ad05f785bb381
Summary:
Updated map view example to correct and extend on change event management
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:
> **Unless you are a React Native release maintainer and cherry-picking an *existing* commit into a current release, ensure your pull request is targeting the `master` React Native branch.**
Explain the **motivation** for making this change. What existing problem does the pull request solve?
Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.
**Test plan (required)**
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
Make sure tests pass on both Travis and Circle CI.
**Code formatting**
Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).
For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests).
Closes https://github.com/facebook/react-native/pull/12759
Differential Revision: D4962286
Pulled By: hramos
fbshipit-source-id: 92cc41f100616d3b5633603cf69850ebc9fc33b2
Summary:
Doing some cleanup in preparation for CRNA.
Recommend `FlatList` and React Navigation for perf.
Tag docs that may only apply to apps ejected from CRNA. Currently has no effect.
Closes https://github.com/facebook/react-native/pull/12692
Differential Revision: D4654077
Pulled By: hramos
fbshipit-source-id: 1245d80d66e37d9dca9e9daf23e8b93c65cd1bf7
Summary:
When creating Native UI Component per docs, it results in duplicate symbols error as explained in issue #12404
Instead of using RCT prefix, it is suggested to use RN prefix to avoid any duplicate symbols.
Closes https://github.com/facebook/react-native/pull/12523
Differential Revision: D4608532
Pulled By: hramos
fbshipit-source-id: 353cfee4bf2cea30706863af51cabe11e9394222
Summary:
We had rendering support for prev links, but we never had any previous links in our metadata. Only next links. This adds that support to both Guides and APIs.
**For guides**: `previous` is manually inserted into the metadata of the actual markdown file.
**For APIs/Components**: `previous` is established via code within `extractDocs.js`
> This isn't totally perfect. For example, the transition from the last guide to the first API/component has a next link from the guide, but not a previous link from the API since the way you get the previous links are different from guides and APIs. But this gets us really close.
Closes https://github.com/facebook/react-native/pull/8754
Differential Revision: D3557972
Pulled By: hramos
fbshipit-source-id: e270bb51e7a4f59f61dad28ae0928d27d0af3d4a
Summary:
Documentation on iOS about triggering events from native components was outdated.
Let me know what you think.
Closes https://github.com/facebook/react-native/pull/6739
Differential Revision: D3240665
Pulled By: mkonicek
fb-gh-sync-id: f62d52bebd58aae6f93388734338ef74ae536ec5
fbshipit-source-id: f62d52bebd58aae6f93388734338ef74ae536ec5
Summary:?` instance to React Native. The layout system suppressed the values for `frame` and `backgroundColor` on my simple view and it wasn't clear why. After some debugging and hacking it became apparent that React Native needed to adjust those properties during layout. The workaround I found was to wrap my custom `UIView` in another `UIView` instance.
**Motivation**
When attempting to bridge a simple 100x100 red background `UIView` to ReactNative I could not get the view to show up as a `RCTView`. The view was there, but it was not 100x100 and it didn't have a red background. After a couple hours of poking around and debugging the call stacks on `setBackgroundColor` and `setFrame` it became apparent that React Native calls those messages on your `UIView` and sends new values. This is likely because of the layout system React Native uses.
I was encouraged to provide a small comment in the documentation if I thought others might find it useful. This PR is an attempt to provide a note in the documentation
Closes https://github.com/facebook/react-native/pull/6786
Differential Revision: D3133093
fb-gh-sync-id: 77d895f2f8e09978d283ee9e3193ee68cc5a7cb8
fbshipit-source-id: 77d895f2f8e09978d283ee9e3193ee68cc5a7cb8
Summary:
public
Due to the cross-platform polyfills we have added (and will add in future) to `UIManager.js`, accessing UIManager directly via NativeModules instead of importing the wrapper is discouraged.
This diff fixes a few places where we were doing this inside our own modules.
Note: As a general policy, we should avoid accessing modules via NativeModules anyway. Using wrapper classes allows us to provide static declarations for all the native methods and properties, which can be checked at build time by flow. If we access the modules directly, those interfaces are only known at runtime.
Reviewed By: vjeux
Differential Revision: D2881300
fb-gh-sync-id: 6737358ea8ea6d722cc1941a4b9fa0123a87fc29
This is an early release and there are several things that are known
not to work if you're porting your iOS app to Android.
See the Known Issues guide on the website.
We will work with the community to reach platform parity with iOS.
This is in preparation for open sourcing React Native for Android.
Also add hyphens to URLs for consistency. This can break people's
browser bookmarks but it's better to be consistent and we can
redirect to docs: https://github.com/facebook/react-native/issues/2137
Test plan: Ran the website locally using `cd website; npm start`
and checked all pages render correctly.
http://i.imgur.com/RrPNgRr.png
Will update "Getting Started", "Tutorial", "Debugging" and
"Testing" separately.