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

100
Vistas
add array of strings into object using 2 functions

I'm creating a NoteEditor, using react. I have 2 textarea in my popup, and when i'm trying to add my array of strings into object, i have a mistake, that my variable, which is contains this arrayOfStrings returns 'undefined', when i'm clicking the button add note.

There is my function onDescriptionChange, i take the e.target.value from my textarea and add to variable arrayOfStrings, where split this string into array with words:

let onDescriptionChange = (e) => {
    setTextAreaHeight(e, '100px');
    let stringToSplit = e.target.value;
    let arrayOfStrings = stringToSplit.split(' ');
    return arrayOfStrings;
};

There is a function addArrayToNote, where I'm trying to add this arrayOfStrings into description:

let addArrayToNote = (arrayOfStrings) => {
    setNote({
        ...note,
        description: arrayOfStrings,
    });
    addNote();
};

I will be very grateful if you help...

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I believe you want to invoke the method addArrayToNote after generating the arrayOfStrings.

let onDescriptionChange = (e) => {
    setTextAreaHeight(e, '100px');
    let stringToSplit = e.target.value;
    let arrayOfStrings = stringToSplit.split(' ');
    // return arrayOfStrings; instead of returning the value
    addArrayToNote(arrayOfStrings) // invoke the addArrayToNote with the strings.

};
let addArrayToNote = (arrayOfStrings) => {
    setNote({
        ...note,
        description: arrayOfStrings,
    });
    addNote();
};

I hope this helps.

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