mirror of
https://github.com/genemecija/learn-morse-code.git
synced 2026-01-23 08:40:18 +01:00
31 lines
964 B
JavaScript
31 lines
964 B
JavaScript
import React, {useContext} from "react"
|
|
import {GameModeContext} from "../contexts/gameModeContext"
|
|
import { MorseBufferContext } from "../contexts/morseBufferContext"
|
|
|
|
function ModePicker() {
|
|
|
|
const {setGameMode} = useContext(GameModeContext)
|
|
const {setMorseCharBuffer} = useContext(MorseBufferContext)
|
|
|
|
function handleClick(e) {
|
|
setMorseCharBuffer('')
|
|
setGameMode(e.target.id)
|
|
console.log("Switched to " + e.target.id + " mode.");
|
|
}
|
|
|
|
return (
|
|
<div id="gameMode" className="mode-picker">
|
|
<button id="practice" onClick={handleClick}>
|
|
Practice
|
|
</button>
|
|
<button id="timed" onClick={handleClick}>
|
|
Timed Mode
|
|
</button>
|
|
<button id="challenge" onClick={handleClick}>
|
|
Challenge Mode
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default React.memo(ModePicker) |