Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handleAddToList = () => {
- let items = [...this.state.items];
- let lastId = Math.max.apply(null, items.id);
- let newId = lastId + 1;
- items.filter(i => i.title == this.state.text).length === 1
- ? alert("This item is on the list already.")
- : items.push({
- id: newId,
- title: this.state.text,
- found: 0,
- value: 0,
- icon: "delete"
- });
- this.setState({ items: items });
- };
- <Input
- placeholder="Start typing"
- label={"Your next shop list item..."}
- onChangeText={text => this.setState({ text })}
- />
- <Button title="Add to list" onPress={() => this.handleAddToList()} />
- Warning: Encountered with two children with the same key, '"-infinity"'.
- <ListItem
- key={l.id}
- title={l.title}
- rightIcon={{ name: l.icon, color: "#cc0033" }}
- bottomDivider={true}
- />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement