Skip to content

Instantly share code, notes, and snippets.

@himelnagrana
Created January 3, 2018 08:32
Show Gist options
  • Save himelnagrana/1dfcd78c28cdebe4e75394069fd890fc to your computer and use it in GitHub Desktop.
Save himelnagrana/1dfcd78c28cdebe4e75394069fd890fc to your computer and use it in GitHub Desktop.
Passing Properties from Native to RN
NSArray *imageList = @[@"http://www.thinkgeek.com/images/products/frontsquare/jvkn_sw_beak_back_buddy.jpg",
@"https://images-na.ssl-images-amazon.com/images/I/41yAU9p60jL._SY300_.jpg"];
NSDictionary *props = @{@"images" : imageList};
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"ImageBrowserTest"
initialProperties:props];
import React from 'react';
import {
AppRegistry,
View,
Image
} from 'react-native';
class ImageBrowserTest extends React.Component {
renderImage(imgURI) {
return (
<Image source={{uri: imgURI}} />
);
}
render() {
return (
<View>
{this.props.images.map(this.renderImage)}
</View>
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => ImageBrowserTest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment