0

I'm using firebase and I want to update a text in a note that the user created.

const [updateInput, setupdateInput] = useState('');

const handleUpdate = (id) => {
  db.collection('notes').doc(id).update({
    details: updateInput,
  });
};
...
<form noValidate autoComplete='off' onSubmit={handleUpdate}>
  <TextField
    onChange={(e) => setupdateInput(e.target.value)}
    defaultValue={note.details}
  />
  <Button type='submit'>Update</Button>
</form>;

I want to give a chance to edit a text in a note but the firestore database doesn't update.

lpizzinidev
  • 12,741
  • 2
  • 10
  • 29
Nedzny
  • 21
  • 6
  • 2
    "It doesn't work." doesn't provide enough information so we can help. What exactly in this code doesn't work the way you expect? Tell us what is wrong with shared code. Do you have any errors? – Alex Mamo Oct 08 '21 at 10:17
  • It doesnt update my firestore database. Ive got an error "Uncaught TypeError: u.indexOf is not a function" – Nedzny Oct 08 '21 at 10:19
  • In that case, these [answers](https://stackoverflow.com/questions/36483151/uncaught-typeerror-indexof-is-not-a-function) will help, right? – Alex Mamo Oct 08 '21 at 10:22
  • What should be the `id` of your `notes` document? – tmarwen Oct 08 '21 at 10:33

0 Answers0