mirror of
https://github.com/genemecija/learn-morse-code.git
synced 2026-04-21 06:03:56 +00:00
Implemented Telegraph Key switching, resolved history clearing bug
This commit is contained in:
parent
c777cf013c
commit
b3436d963b
13 changed files with 86 additions and 120 deletions
|
|
@ -1,24 +1,19 @@
|
|||
import React, {Component} from "react"
|
||||
import React, {useState} from "react"
|
||||
|
||||
const KeyTypeContext = React.createContext()
|
||||
|
||||
class KeyTypeContextProvider extends Component {
|
||||
state = {
|
||||
keyType: "electronic"
|
||||
}
|
||||
|
||||
switchKeyType = (type) => {
|
||||
this.setState({keyType: type})
|
||||
}
|
||||
function KeyTypeContextProvider(props) {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<KeyTypeContext.Provider value={{keyType: this.state.keyType, switchKeyType: this.switchKeyType}}>
|
||||
{this.props.children}
|
||||
</KeyTypeContext.Provider>
|
||||
)
|
||||
}
|
||||
const [keyType, setKeyType] = useState('straight')
|
||||
|
||||
return (
|
||||
<KeyTypeContext.Provider value={{
|
||||
keyType: keyType,
|
||||
setKeyType: setKeyType
|
||||
}}>
|
||||
{props.children}
|
||||
</KeyTypeContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export {KeyTypeContextProvider, KeyTypeContext}
|
||||
|
|
|
|||
|
|
@ -3,28 +3,10 @@ import React, {useState} from "react"
|
|||
const MorseBufferContext = React.createContext()
|
||||
|
||||
function MorseBufferContextProvider(props) {
|
||||
// state = {
|
||||
// morseCharBuffer: '',
|
||||
// morseWords: []
|
||||
// //morseCharBuffer, morseWords, clearHistory, setMorseCharBuffer, setMorseWords
|
||||
// }
|
||||
console.log('MorseBufferContextProvider LOADED');
|
||||
|
||||
const [morseCharBuffer, setMorseCharBuffer] = useState('')
|
||||
const [morseWords, setMorseWords] = useState([])
|
||||
|
||||
|
||||
// switchKeyType = (type = "straight") => {
|
||||
// this.setState({keyType: type})
|
||||
// }
|
||||
|
||||
// setMorseCharBuffer = (value) => {
|
||||
// this.setState({morseCharBuffer: value})
|
||||
// }
|
||||
// setMorseWords = (value) => {
|
||||
// this.setState({morseWords: value})
|
||||
// }
|
||||
|
||||
// render() {
|
||||
return (
|
||||
<MorseBufferContext.Provider value={{
|
||||
morseCharBuffer: morseCharBuffer,
|
||||
|
|
@ -35,8 +17,6 @@ function MorseBufferContextProvider(props) {
|
|||
{props.children}
|
||||
</MorseBufferContext.Provider>
|
||||
)
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
export {MorseBufferContextProvider, MorseBufferContext}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue