Git Product home page Git Product logo

tic-tac-toe's Introduction

TIC-TAC-TOE

This will create an interactive tic-tac-toe game . The main motive is to learn React while doing projects.

It uses the concept of state, component and props .

Here, initially all the squares in the box are taken null where each box has its own state completely independent of each other.

State of a box changes only when the square/box is clicked showing 'X' or 'O' depending on the turn. The state changes on clicking the button where by calling this set function from an onClick handler, that Square is re-rendered whenever its is clicked.

The square state variable declared under the parent component initially creates an array of 9 elements and sets each value to 'null'. The useState() call around it declares a squares state variable that’s initially set to that array. Each entry in the array corresponds to the value of a square. Now, the parent component needs to pass the state or prop down to each of the Square that it renders.

  • The state of the board(parent) component is changed to current state by rendering handleClick(),
  • handleClick alters the state of the board component by calling the setSquares component.
  • All the statemanagement is handled by the board component (parent)

Time Travel: Can update as with respect to time

  • can go to the previous move
  • shows the current status

tic-tac-toe's People

Contributors

samadritabhattacharya avatar

Watchers

 avatar

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.