Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Reactjs: ¿Por qué mi dispositivo virtual Android muestra 'this.setState_if_Tie' no es una función?

Estoy tratando de hacer una función de juego de tic-tac-toe en mi aplicación móvil usando react-native. Pero cuando el usuario ganó el juego, el juego no detuvo la ronda, en cambio, el juego continúa hasta que se llenan todos los espacios y aparece un error que dice que " this.setState_if_Tie no es una función".

En cambio, cuando el resultado sea un empate, la pantalla se congelará en blanco.

A continuación se muestran algunos códigos que están relacionados con dicho problema:

 judgeWinner(inputs){ //check the winning situation based on 'const conditions' return conditions.some(d => d.every(item => inputs.indexOf(item) !== -1)); } //if result === -1 game continue , result === 0 user won //if result === 1 bot won , result === 2 no winner setstate_if_Win(parse_res, parse_result){ if (parse_res && parse_result !== 0){ this.setState({ result: 0}); //User win } if (parse_res && parse_result !== 1) { this.setState({ result: 1}); //Bot win } } setstate_if_Tie = () => { this.setState({ result: 2 }); } componentDidUpdate() { const { userInputs , botInputs , result} = this.state; const inputs = userInputs.concat(botInputs); //res is result if (inputs.length >= 5) { let res = this.judgeWinner(userInputs); // go to line 95 to check winning result for user if (res && result !== 0) { this.setstate_if_Win(res, result); //User win return; } res = this.judgeWinner(botInputs); // go to line 95 to check winning result for bot if (res && result !== 1) { this.setstate_if_Win(res, result); //Bot win return; } } if (inputs.length >= 9 && result !== 2) { this.setState_if_Tie(); //No winner (Tie) } }

¿Hay alguna manera que pueda hacer para resolver este problema? Gracias de antemano.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe nombrar setState_if_Tie en lugar de setstate_if_Tie:

 setstate_if_Tie = () => { this.setState({ result: 2 }); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!