I am using List to render the data vertically. Docs suggests a way for hardcoded data but I have data in an array.
Docs have this example :
<MobileTearSheet>
<List>
<ListItem primaryText="Inbox" leftIcon={<ContentInbox />} />
<ListItem primaryText="Starred" leftIcon={<ActionGrade />} />
<ListItem primaryText="Sent mail" leftIcon={<ContentSend />} />
<ListItem primaryText="Drafts" leftIcon={<ContentDrafts />} />
<ListItem primaryText="Inbox" leftIcon={<ContentInbox />} />
</List>
<Divider />
<List>
<ListItem primaryText="All mail" rightIcon={<ActionInfo />} />
<ListItem primaryText="Trash" rightIcon={<ActionInfo />} />
<ListItem primaryText="Spam" rightIcon={<ActionInfo />} />
<ListItem primaryText="Follow up" rightIcon={<ActionInfo />} />
</List>
</MobileTearSheet>
I have todos array which I want to render in a ListItem. Can anyone suggest me how to do ?
this.state = {
open: false,
todos: [],
notetext: ""
};
I am adding elements in an array as below:
todos.push({
id: todos.length,
text: this.state.notetext,
completed: false
});
mapfunction to iterate over the array and create new ListItems that are passed each todo to their props.