0

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

3
  • the json data where do you keep that. Commented Oct 1, 2018 at 8:32
  • Make a const for the json data and export it from that file and then import it in the file where you want to use. Commented Oct 1, 2018 at 8:33
  • hey @knevagi, it would be really easy to help you if you can share your code on the snack.expo.io Commented Oct 1, 2018 at 8:44

1 Answer 1

1

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}
            />
        );
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Oh man that worked. Thank you so much. Can you please explain what you did?
ListView is no longer used. You should use FlatList instead. facebook.github.io/react-native/docs/flatlist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.