xxxgitone / reactapp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

create-react-app的使用

  • 安装: yarn global add create-react-app --prefix /usr/local
  • 创建项目 create-react-app project
  • 启动 yarn start
  • 默认配置文件隐藏,使用yarn eject显示

JSX基础语法

  • JS里直接写html
  • class要写成className
  • 变量用{}包裹

Redux

Redux是专注于状态管理的库
  • Redux专注于状态管理,和react解耦
  • 单一状态,单项数据流
  • 核心概念: store,state,action,reducer

react-redux的使用

  • Provider组件在应用最外层,传入store即可,只用一次
  • Connect负责从外部获取组件需要的参数

react-router4

  • BrowserRouter,包裹整个应用
  • Router路由对应渲染组件,可嵌套
  • Link跳转专用

About


Languages

Language:JavaScript 97.0%Language:HTML 2.3%Language:CSS 0.7%