Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda