Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
Updating an array in Firestore: Uncaught TypeError: options is not a function

I am trying to update these options in Firestore:

enter image description here

For editing the category, it does sucessfully update it. But for the options array, this is the error it displays:

Uncaught TypeError: options is not a function

const [category, setCategory] = useState([]);
//useEffect to get all of the categories


const [options, setOptions] = useState([]);
const [edit, setEdit] = useState();


const handleSubmit = async (e) => {
    e.preventDefault();

    const ref = doc(db, "category", state);
    await updateDoc(ref, {
      category: edit,
    });
    console.log("updated");
  };

Forms

I am using a defaultValue to show the initial value that was saved from Firestore.

 {category &&
          category.map((category, index) => (
            <form onSubmit={handleSubmit}>
                  <TextField
                    defaultValue={category.cat}
                    type="text"
                    value={categoryEdit}
                    fullWidth
                    onChange={(e) => setCategoryEdit(e.target.value)}
                  />
                      {category.options.map((i) => (
                        <TextField
                          type="text"
                          defaultValue={i}
                          variant="outlined"
                          fullWidth
                          value={options(i)}
                          onChange={(e) => setOptions(e.target.value(i))}
                        />
                      ))}
         
                  </>
                )}
                <Button type="submit">Submit</Button>
            </form>
          ))}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This has nothing to do with updating Firestore.

options is an array, but you're calling it like a function here using parenthesis:

value={options(i)}

If you want to index into the array, use square brackets, not parens.

value={options[i]}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda