I am trying to create an edit function for updating a task that was previously written.
I have tried this so far but apparently the prompt is only for the browser. Would this even work? What are alternatives to create the prompt for react native?
const taskUpdate = (index) => {
const newItemsCopy = [...taskItems];
const item = newItemsCopy[index];
let newItem = prompt(`Update ${item.task}?`, item.task);
let todoObj = { todo: newItem, complete: false };
newItemsCopy.splice(index, 1, todoObj);
if (newItem === null || newItem === "") {
return;
} else {
item.task = newItem;
}
setTaskItems(newTodoItems);
}
2
Answers
You can use Alert from react-native.
You can implement this using Modal