简体   繁体   中英

React Native: “undefined is not an object” Rendering components with ListView and external dataSource

I have a Container component that should render a ListView.

The ListView's dataSource needs to call an external (But local) JSON file with a list of "reservations".

The ListView should render a new "card" for each entry in the JSON file with a title.

However, I get the following error:

undefined is not an object (evaluating 'this.props.dataSource.title')

Below is a gist of my code ... what am I doing wrong?

https://gist.github.com/chapeljuice/316cb72432bf0d3ff90ca93349b85570

i think if you use

this.props.data.title

or

this.props.title

instead of

this.props.dataSource.title

you can get answer. because when you pass data to 'ReservationCard', data will be as props to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM