Answer the question
In order to leave comments, you need to log in
Async in react?
Good day.
I am writing a simple todo in react + rudux.
The crux of the problem:
We have a todoDelete function that takes an id, then runs through the array of todos and deletes the desired element.
Next, we dispatch our action addTodos, which takes the current array of todos and updates it in the redux state.
After that, we must store our new todo array in localstorage, which is done by the addTodosToLocalStorage function .
todoDelete = (id) => {
const { todos } = this.props;
const newTodoList = todos.filter(item => item.id !== id);
this.props.addTodos(newTodoList);
setTimeout(() => this.addTodosToLocalStorage(), 0);
}
this.props.addTodos(newTodoList);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question