From 3ceb20de7410d7c0efe8dda05064441fafc17405 Mon Sep 17 00:00:00 2001 From: Ian Hill Date: Tue, 12 Sep 2017 13:33:15 -0700 Subject: [PATCH] Minor documentation correction for exposing native iOS components 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 --- docs/NativeComponentsIOS.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/NativeComponentsIOS.md b/docs/NativeComponentsIOS.md index fa797ff96cdb4b..a5744c914a623b 100644 --- a/docs/NativeComponentsIOS.md +++ b/docs/NativeComponentsIOS.md @@ -67,10 +67,10 @@ import MapView from './MapView.js'; render() { return ; -} +} ``` -Make sure to use `RNTMap` here. We want to require the manager here, which will expose the view of our manager for use in Javascript. +Make sure to use `RNTMap` here. We want to require the manager here, which will expose the view of our manager for use in Javascript. **Note:** When rendering, don't forget to stretch the view, otherwise you'll be staring at a blank screen. @@ -97,8 +97,8 @@ Now to actually disable zooming, we set the property in JS: ```javascript // MyApp.js -; ``` @@ -119,7 +119,7 @@ class MapView extends React.Component { MapView.propTypes = { /** - * A Boolean value that determines whether the user may use pinch + * A Boolean value that determines whether the user may use pinch * gestures to zoom in and out of the map. */ zoomEnabled: PropTypes.bool, @@ -196,7 +196,7 @@ To finish up support for the `region` prop, we need to document it in `propTypes MapView.propTypes = { /** - * A Boolean value that determines whether the user may use pinch + * A Boolean value that determines whether the user may use pinch * gestures to zoom in and out of the map. */ zoomEnabled: PropTypes.bool, @@ -233,8 +233,8 @@ render() { longitudeDelta: 0.1, }; return ( - @@ -244,7 +244,7 @@ render() { Here you can see that the shape of the region is explicit in the JS documentation - ideally we could codegen some of this stuff, but that's not happening yet. -Sometimes your native component will have some special properties that you don't want to them to be part of the API for the associated React component. For example, `Switch` has a custom `onChange` handler for the raw native event, and exposes an `onValueChange` handler property that is invoked with just the boolean value rather than the raw event. Since you don't want these native only properties to be part of the API, you don't want to put them in `propTypes`, but if you don't you'll get an error. The solution is simply to add them to the `nativeOnly` option, e.g. +Sometimes your native component will have some special properties that you don't want to be part of the API for the associated React component. For example, `Switch` has a custom `onChange` handler for the raw native event, and exposes an `onValueChange` handler property that is invoked with just the boolean value rather than the raw event. Since you don't want these native only properties to be part of the API, you don't want to put them in `propTypes`, but if you don't you'll get an error. The solution is simply to add them to the `nativeOnly` option, e.g. ```javascript var RCTSwitch = requireNativeComponent('RCTSwitch', Switch, { @@ -256,7 +256,7 @@ var RCTSwitch = requireNativeComponent('RCTSwitch', Switch, { So now we have a native map component that we can control easily from JS, but how do we deal with events from the user, like pinch-zooms or panning to change the visible region? -Until now we've just returned a `MKMapView` instance from our manager's `-(UIView *)view` method. We can't add new properties to `MKMapView` so we have to create a new subclass from `MKMapView` which we use for our View. We can then add a `onRegionChange` callback on this subclass: +Until now we've just returned a `MKMapView` instance from our manager's `-(UIView *)view` method. We can't add new properties to `MKMapView` so we have to create a new subclass from `MKMapView` which we use for our View. We can then add a `onRegionChange` callback on this subclass: ```objectivec // RNTMapView.h @@ -344,15 +344,15 @@ class MapView extends React.Component { if (!this.props.onRegionChange) { return; } - - // process raw event... + + // process raw event... this.props.onRegionChange(event.nativeEvent); } render() { return ( - ); } @@ -381,8 +381,8 @@ class MyApp extends React.Component { }; return ( ); @@ -443,4 +443,4 @@ The `RCTDatePickerIOSConsts` constants are exported from native by grabbing the } ``` -This guide covered many of the aspects of bridging over custom native components, but there is even more you might need to consider, such as custom hooks for inserting and laying out subviews. If you want to go even deeper, check out the [source code](https://github.com/facebook/react-native/blob/master/React/Views) of some of the implemented components. +This guide covered many of the aspects of bridging over custom native components, but there is even more you might need to consider, such as custom hooks for inserting and laying out subviews. If you want to go even deeper, check out the [source code](https://github.com/facebook/react-native/blob/master/React/Views) of some of the implemented components.