参考文件:react tutorial:https://reactjs.org/
1: 安装Node.js 第一次在Linux上安装,但是版本不够新用不了npx 后来update了很久才成功。
macOS安装很简单。 Node >= 8.10 and npm >= 5.6才能用npx指令。
2: npx create-react-app appname
cd appname
npm start
三条指令开启react项目,成功后会看到react标志的页面。
3:先从这里开始 https://reactjs.org/docs/hello-world.html
几点重点:1)React从上到下编译代码。
2)this.setstate赋值:正确做法:this.setstate({ var: 'Hello'});不应该用this.state.var='Hello';
3) this.state和this.props会异步更新。
4)同一个state的更新是会被merged的,所以可以分开更新state。