Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1;
- 2;
- 3;
- 2;
- deleteNote (index) {
- let arr = this.state.lies;
- console.log(arr); //
- arr = arr.splice(index, 1);
- console.log(arr); //
- this.setState({lies : arr});
- }
- render () {
- let lies = this.state.lies.map( (item, index) => {
- return item = <NewLi
- text = {item.text}
- key = {item.id}
- id = {index}
- deleteNote = {this.deleteNote.bind(this)}
- />;
- })
- function NewLi (props) {
- return(
- <div>
- <li>{props.text}</li>
- <button onClick = {() => props.deleteNote(props.id)}> X </button>
- </div>
- );
- }
- module.exports = NewLi;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement