ios - Want to pass data to other component - ListView -
i have added , imported sample data. want list out data file in list view , i'm passing data row component renderrow. getting error saying
row(...): valid react element (or null) must returned. may have returned undefined, array or other invalid object.
import react, { component } 'react'; import { appregistry, view, listview, text, stylesheet } 'react-native'; import row './app/row'; import data './app/data'; export default class listviewdemo extends component { constructor(props) { super(props); const rowhaschanged = (r1, r2) => r1 !== r2 const ds = new listview.datasource({rowhaschanged}); this.state = { datasource: ds.clonewithrows(data), }; render() { return ( <listview datasource={this.state.datasource} renderrow={(data) => <row {...data} />} // getting error here /> ); } } appregistry.registercomponent('demoapp',() => listviewdemo) these sample data.js can check data here.
export default data = [ {...}, {...} ]; row.js:
const row = (props) => { <view style={styles.container}> <image source={{ uri: props.picture.large}} /> <text > {`${props.name.first} ${props.name.last}`} </text> </view> } what problem?
es6 returns when there no explicit blocks:
const cb = (param) => param * 2; you should explicitly return:
const row = (props) => { return ( <view style={styles.container}> <image source={{ uri: props.picture.large}} /> <text > {`${props.name.first} ${props.name.last}`} </text> </view> ); } check answer further explanation.
Comments
Post a Comment