building a Tic Tac Toe game with React.js
- Facebook tutorial
- Building dynamic forms with Facebook React
- React Tutorial: Two way data binding
- Learn basics of React.js making the tests pass
- Simplifying Code with React
- Building a board game with React.js
- Fork the repository.
git clone https://github.com/YOUR_USERNAME/tic-tac-toe.git
- Install dependencies
❯ npm i -g gulp
❯ npm i
- Once installed, run the default gulp task
❯ gulp
- Open
index.html
in your browser of choice. - Follow the steps below to build Tic Tac Toe in the file
lib/app.jsx
- Your changes to
app.jsx
will auto rebuild your application. - Reload your browser to see changes.
Note: If you get stuck, look at the docs here
Please, solve each step in a separate message commit:
❯ git commit -m "step 2"
❯ git commit -m "step 3"
❯ git commit -m "step 4 and 5"
The Box
is a button
render the X
value.
Tips: First component
Render (again) the X
value.
Tips: Using props
Set
height
to100px
width
to100px
Tips: Inline styles
Render (again) the X
value
as initial state.
Name it initialValue
.
Tips: Props in getInitialState Is an Anti-Pattern
Every 300ms, change by alternating the state value
between X
and O
Tips: Lifecycle Methods
Make Box value alternates between X
and O
on clicks.
Tips: DOM Event Listeners in a Component
Row
renders 3 Box
components
Tips: Composition Example
Row
render 3
children Box
with -
as initial value.
Tips: Dynamic Children
Now, the event click
changes the state of the Row
component
Tips: Save the value for each row index.
Now, create a Grid
component that renders 3 Row
components.
Tips: Same as 7 ;)
Grid
render 3
children Row
with -
as initial value.
Tips: Same as 8 ;)
Now, the event click
changes the state of the Grid
component
Tips: Save the value for each row/column index inside the grid (and same as 9 ;))