Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!