How can I get this to work, {showExamples} isn't showing any output. The full source code is here: https://rnplay.org/apps/t2E4Ig
var MyApp = React.createClass({
render() {
var showExamples = examples.map(function(value){
return (
<View>
{value.render}
</View>
);
});
return (
<View>
<Image
source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
style={styles.base}
/>
{showExamples}
</View>
);
}
});
In React, the map method is used to traverse and display a list of similar objects of a component. A map is not a feature of React. Instead, it is the standard JavaScript function that could be called on an array. The map() method creates a new array by calling a provided function on every element in the calling array.
The rendered Maps can be printed directly from the browser by calling the print method. To use the print functionality, the Print module must be injected into the Maps using Inject services={[]} tag and set the allowPrint property to true.
you can try this.
var MyApp = React.createClass({
render() {
return (
<View>
<Image
source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
style={styles.base}
/>
{
examples.map(function(value, i){
return (
<View key={i}>
{value.render}
</View>
);
})
}
</View>
);
} });
The render
property on each of the example items is a function, so you need to invoke it with {value.render()}
, instead of trying to "render a function: with {value.render}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With