reactjsfirebasegoogle-cloud-firestorematerial-uimui-x-data-grid

s.indexOf is not a function at Function.n.fromString


I have no idea why I'm getting this error or from where is coming from because I think I'm not using that ?

I'm doing a firebase update after an user update a row from DataGrid MUI and I'm doing the update as I would normally do nothing different at all and it just jumps into that error.

I'm not sure if is an React error, JS error, Firebase error, MUI error. but I THINK is a firebase error because the path says so

enter image description here

enter image description here

This is what I was trying to do:

const [editRowsModel, setEditRowsModel] = React.useState({});
const [editRowData, setEditRowData] = React.useState({});

const handleEditRowsModelChange = React.useCallback(
  (model) => {
    const editedIds = Object.keys(model);

    if (editedIds.length === 0) {
      
      console.log(editRowData)
      console.log(editRowData.uid)
      console.log(editRowData.nombre)
      console.log(editRowData.colegio)
      console.log(editRowData.grado)
      
      const temporalQuery = db.collection("usuarios").doc(user.uid).collection("estudiantes").doc(editRowData.uid);
              temporalQuery.update({
                nombre: editRowData.nombre,
                colegio: editRowData.colegio,
                grado: editRowData.grado
              })
    } else {
      setEditRowData(model[editedIds[0]]);
    }
    setEditRowsModel(model);
  },
  [editRowData]
);

This is what the console.log shows up. I honestly don't see any error in the way I code it that's how I always do it, never had an issue before. First time I update from a nested collection though

enter image description here

This is how it looks in the firebase

enter image description here

And yes the user.uid also comes correctly

enter image description here


Solution

  • Found the issue is because the data comes with a whole string of information instead of just the value as I though it was coming.

    All I had to do was to call the field + the value when I was using it. Ej:

    if I wanted the uid I had to call it editRowData.uid.value