import React, { useContext } from "react" import morseCode from '../data/morse-code.json' import useMorsePlayer from "../hooks/useMorsePlayer"; import { WPMContext } from "../contexts/wpmContext.js"; function Legend() { const { playMorseWord } = useMorsePlayer() function handleClick(e) { e.preventDefault() let word = e.target.innerText // let newWord = word if (e.target.className === 'alpha') { word = convertWordToMorse(word) } if (e.target.id === 'test') { word = convertWordToMorse(e.target.innerText) } console.log(word); playMorseWord(word) } function convertWordToMorse(word) { let morse = '' for (let i in word) { morse += morseCode[word[i].toLowerCase()] morse += ' ' } return morse } const legend = Object.keys(morseCode).map((morse, index) => ) return (

Morse Code

{legend}
) } export default React.memo(Legend)