Tianhe Gao

react

https://create-react-app.dev/

​## Tutorial: Intro to React

https://reactjs.org/tutorial/tutorial.html

React Component

React.createElement()

State

> React is a declarative, efficient, and flexible JavaScript library for building user interfaces.

  • props(properties)

> In [JavaScript classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), you need to always call `super` when defining the constructor of a subclass. All React component classes that have a `constructor` should start with a `super(props)` call.

> To collect data from multiple children, or to have two child components communicate with each other, you need to declare the shared state in their parent component instead. The parent component can pass the state back down to the children by using props; this keeps the child components in sync with each other and with the parent component.

> Immutability Is Important

`concat()`, `map()` 的经常使用。

> Each child in an array or iterator should have a unique "key" prop.

​### 关于教程的进一步练习:

Display the location for each move in the format (col, row) in the move history list.

Bold the currently selected item in the move list.

Rewrite Board to use two loops to make the squares instead of hardcoding them.

Add a toggle button that lets you sort the moves in either ascending or descending order.

When someone wins, highlight the three squares that caused the win.

When no one wins, display a message about the result being a draw.


No notes link to this note