Giter Club home page Giter Club logo

Comments (6)

daigoro22 avatar daigoro22 commented on June 17, 2024

<td>要素を一つ持つコンポーネント
state 中にマルかバツのテキストを持つ

from bootcampreacttictactoe.

daigoro22 avatar daigoro22 commented on June 17, 2024

親のゲームボードからマスの state を参照できる形にしなくてはならない
解決策の候補

  • useContext
  • 子に親の state を更新するコールバック関数を props を通じて渡す

from bootcampreacttictactoe.

daigoro22 avatar daigoro22 commented on June 17, 2024

useContextを使えば、親コンポーネントの state と setState 関数を一度に子のコンポーネントに渡すことができる

from bootcampreacttictactoe.

daigoro22 avatar daigoro22 commented on June 17, 2024

GameBoard コンポーネントのfilledBy state を、Boxコンポーネントから設定
filledByはゲームのマス分の長さを持った String 型のリスト
Boxがリストのどのインデックスの値を変更するかは props から指定

from bootcampreacttictactoe.

daigoro22 avatar daigoro22 commented on June 17, 2024

onClicksetState(を呼び出す)関数そのものではなく、その返り値を指定した場合、render内で state を更新することになり、無限ループしてしまう。

from bootcampreacttictactoe.

daigoro22 avatar daigoro22 commented on June 17, 2024
  //これだと、splice が破壊的なのでダメ
  // filledBy を直接編集していることになってしまう
  filledBy.splice(filledByIndex,1,currentPlayer)
  setFilledBy(filledBy)

from bootcampreacttictactoe.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.