Knevagi
Knevagi

Reputation: 157

TypeError: Undefined is not an object error in React Native

I am fairly new to react native and I am trying to render json data on the android emulator, however, I am getting an error which I have no idea about. Will appreciate any help I can get.

LibraryList.js

ListItems.js

The json data trying to be rendered

App.js

The error shown on the emulator

Upvotes: 0

Views: 1289

Answers (1)

Fatih Bulut
Fatih Bulut

Reputation: 2657

Could you replace your class code in LibraryList.js with this?

class LibraryList extends Component {
    renderRow(library) {
        return <ListItems library={library} />;
    }

    render() {
        return(
            <FlatList
                data={this.props.libraries}
                renderItem={({item}) => <Text>{item.title}</Text>}
                keyExtractor={item => item.title}
            />
        );
    }
}

Upvotes: 1

Related Questions