I developing basic word game.
I have a js class: word.ts and react project.
This is my class
class WordGame {
words: string[]
gameOver: boolean
usedWords: string[]
whoseTurn: 'player' | 'computer' | 'none'
activeWord: string
constructor(wordList: string[]) {
this.words = wordList
this.gameOver = false
this.usedWords = []
this.whoseTurn = 'none'
this.activeWord = ''
}
private updateActiveWord(word: string) {
this.activeWord = word.toLowerCase()
//----> I want to dispatch event on this step <----
}
}
How to dispatch event after update this.activeWord. And how to listen from react component.