React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug.
Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.
build an interactive tic-tac-toe game
We have three components:
- Square
- Board
- Game
The Square component renders a single button, the Board renders 9 squares, and the Game component renders a board with some placeholders.
index.html
1 |
|
index.js
1 | class Game extends React.Component{ |