Created
January 3, 2018 08:32
-
-
Save himelnagrana/1dfcd78c28cdebe4e75394069fd890fc to your computer and use it in GitHub Desktop.
Passing Properties from Native to RN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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