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

185
Views
React Native Java Script import array of words

I am trying to import an array of words into my hangman game, however, I am encountering an error

Cannot read properties of undefined (reading 'split') Word /src/components/Word.js:8:20 5 | 6 | return ( 7 |

8 | {selectedWord.split('').map((letter, i) => { | ^ 9 | return ( 10 | 11 | {correctLetters.includes(letter) ? letter : ''}

Here is the Words.js file where the error appears to be occurring on line 8:

import React from 'react';

// rendering the list of correct words
const Word = ({ selectedWord, correctLetters }) => {

  return (
    <div className="word">
      {selectedWord.split('').map((letter, i) => {
        return (
          <span className="letter" key={i}>
            {correctLetters.includes(letter) ? letter : ''}
          </span>
        )
      })}
    </div>
  )
}

export default Word

Any help to fix this problem would be much appreciated, Thanks :)

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

0

You are exporting hangmanArray as a function that returns the words when executed. Either you should call it before using and store in a variable or export the words array directly.

const words = hangmanArray()

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!