Use requireNativeComponent with propTypes for Android components.

Reviewed By: davidaurelio

Differential Revision: D2663502

fb-gh-sync-id: 550e7b7c783ec0463a6beb052c09a768a8086056
This commit is contained in:
Krzysztof Magiera
2015-11-18 05:32:46 -08:00
committed by facebook-github-bot-4
parent ca20d710fc
commit e6093cff04
6 changed files with 30 additions and 9 deletions

View File

@@ -6,10 +6,11 @@
*/
'use strict';
var Platform = require('Platform');
var NativeMethodsMixin = require('NativeMethodsMixin');
var Platform = require('Platform');
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
var requireNativeComponent = require('requireNativeComponent');
@@ -23,6 +24,7 @@ type DefaultProps = {
*/
var Switch = React.createClass({
propTypes: {
...View.propTypes,
/**
* The value of the switch. If true the switch will be turned on.
* Default value is false.
@@ -115,7 +117,7 @@ var styles = StyleSheet.create({
});
if (Platform.OS === 'android') {
var RCTSwitch = requireNativeComponent('AndroidSwitch', null, {
var RCTSwitch = requireNativeComponent('AndroidSwitch', Switch, {
nativeOnly: { onChange: true, on: true, enabled: true }
});
} else {