react

START

import React,{Component} from 'react'
  
class Index extends Component {
  constructor(props){
    super(props);
    this.state = {};
  }
  render() {
    return (
      <div>this is text</div>
    )
  }
}
  • 只能有一个root tag
  • 无论单个tag还是成对的tag都必须有闭合( / )
  • class 必须首字母大写( Index )

PropTypes

import React,{Component} from 'react'
import PropsTypes from 'prop-types'
class Index extends Component {
  constructor(props){
    super(props);
    this.state = {};
  }
  render() {
    return (
      <div>this is text</div>
    )
  }
}
  • import PropsTypes from 'prop-types'不要写成 import React,{Component,PropTypes} from 'react' 这样会警告,虽然不会报错(请养成好习惯)
  • 验证类型请参考官网(官网很详细)

包管理工具 (自行转官网文档 start)

  • react官网推荐的 create-react-app
  • antd推荐的 dva
推荐学习资料 (自行百度)
  • react小书
  • react-router github
  • redux 正在学习中...
UI 推荐 (目前只接触过这两个)
  • antd
  • antd mobile
注意
  • 不论是看视频还是看学习资料,有时发现自己的本地环境运行不了,有可能是安装的版本原因
  • 这个时候看看package.json
  • 如果有^,去掉后再安装,或者直接安装对应版本号(不会去百度npm)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容