1

I've written for loop to fetch objects from array one by one, but the result fetched all of objects from loop and repeated those in one string.

Here is my code:

state = {
    b: ["A","B","C","D","E","F","G","H","I"]
}

b = () => {
    let d = [];
    for (var i =0; i<=this.state.b.length - 1; i++) {
        d.push(this.state.b[i])
    }
    return d;
};

I'm beginner in react native, how can I change this code to show object arrays like a list

1 Answer 1

2

You can use ListView directly like this :

<ListView
    dataSource={this.state.b}
    renderRow={(rowData) => <Text>{rowData}</Text>}
/>
Sign up to request clarification or add additional context in comments.

2 Comments

I got this error listview has been removed from react native
try FlatList inplace

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.