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

99
Views
React generating UI from object - console.log works but nothing generated

I have code that generates my react UI, and it works with a list of languages to generate checkboxes for language selection. For example when in state

languages = {English: true, French: false} 

however when i change it to an object which contains the values from the DB, I get no error, but nothing loads.

[
{
    "language_name": "English",
    "lang_num": 1,
    "checked": false
},
{
    "language_name": "Mandarin Chinese",
    "lang_num": 2,
    "checked": false
},
]

The code is:

       {   
        Object.entries(this.props.languages).forEach(([key, value]) => {
          console.log(this.props.languages[key].language_name),
          <label id="checkbox-margin">
            <input
              type="checkbox"
              value={this.props.languages[key].language_name}  
              checked={this.props.languages[key].checked}
              onChange={this.handleLangClick}
            /> {this.props.languages[key].language_name}
          </label>
      }
      )

The console.log lists each language string fine, i get them all printed in the console, but nothing is generated on the UI. Any idea why?

Thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try to use the map function to iterate through the array:

{this.props.languages ? this.props.languages.map(language => {
    return (
        <label id="checkbox-margin" key={language.lang_num}>
            <input
                type="checkbox"
                value={language.language_name}  
                checked={language.checked}
                onChange={this.handleLangClick}
            /> {language.language_name}
        </label>
    )}) : 'Loading languages...'
}
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!