Próbuję wywołać ShuffleCards podczas zdarzenia click w komponencie ReactJs. Jednak ja otrzymuję następujący błąd:React JS Uncaught Błąd odniesienia: funkcja nie zdefiniowana
Uncaught ReferenceError: shuffleCards is not defined
Oto mój kod:
constructor(props) {
super(props);
this.state = {
count: 0
};
}
shuffleCards(array) {
var i = array.length,
j = 0,
temp;
while (i--) {
j = Math.floor(Math.random() * (i+1));
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
handleClickEvent(event) {
var cards = [
{txt: "A",
isDisplayed: false},
{txt: "B",
isDisplayed: false},
{txt: "C",
isDisplayed: false}
];
if (this.state.count == 0) {
cards = shuffleCards(cards);
}
}
'this.shuffleCards' – zerkms
@zerkms wow nie może uwierzyć, że zrobił myśleć robi. zadziałało. dzięki! – janeeyrea