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

183
Vistas
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 Respuestas
Responde la pregunta

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 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