Skip to content

《深入浅出React与Redux》(进行中) #1

@qiansc

Description

@qiansc

Part.1 React新的前端思维方式
略(Hello Demo)

Part.2 设计高质量的React组件

  • Prop定义外部接口、State定义内部状态
  • Prop+State 作为 Render的Data输入决定视图 UI = render(data)
  • React组件生命周期
    • Mount
      • constructor
      • getInitialState
      • getDefaultProps
      • componentWillMount
      • render
      • componentDidMount
    • Update
      • componentWillReceiveProps
      • shouldComponentUpdate
      • render
      • componentDidUpdate
    • Unmount
      • componentWillUnmount (通常和componentDidMount有关)
  • 组件向外传递数据(Based On Props)
  • 局限性:组件与子组件维护重复的数据 -> Redux方案管理全局Data
  • PropTypes
    • Demo在新版本下问题:PropTypes已经不从react库引入 -> import PropTypes from 'prop-types'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions