Skip to content

Commit bb79d03

Browse files
committed
Add comments about nativeOnly props
1 parent 322807b commit bb79d03

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

docs/NativeComponentsIOS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ MapView.propTypes = {
212212

213213
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.
214214

215+
Sometimes you'll have some special properties that you need to expose for the native component, but don't actually want them as 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 call them out via the `nativeOnly` option, e.g.
216+
217+
```javascript
218+
var RCTSwitch = requireNativeComponent('RCTSwitch', Switch, {
219+
nativeOnly: { onChange: true }
220+
});
221+
```
222+
215223
## Events
216224

217225
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? The key is to make the `RCTMapManager` a delegate for all the views it vends, and forward the events to JS via the event dispatcher. This looks like so (simplified from the full implementation):

0 commit comments

Comments
 (0)