Skip to content

Instantly share code, notes, and snippets.

@alphatr
Created June 4, 2015 11:29
Show Gist options
  • Save alphatr/eb6a5fe413611a11fd53 to your computer and use it in GitHub Desktop.
Save alphatr/eb6a5fe413611a11fd53 to your computer and use it in GitHub Desktop.
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
requireNativeComponent,
PropTypes,
View
} = React;
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
customView: {
width: 10,
height: 10
}
});
var _MyCustomView = React.createClass({
propTypes: {
isRed: PropTypes.bool
},
render: function () {
return <CustomView {...this.props}/>;
}
});
var CustomView = requireNativeComponent('MyCustomView', _MyCustomView);
var MyCustomView = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text>Red one</Text>
<_MyCustomView style={styles.customView} isRed={true}/>
<Text>Not red one</Text>
<_MyCustomView style={styles.customView} isRed={false}/>
</View>
);
}
});
AppRegistry.registerComponent('MyCustomView', () => MyCustomView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment