Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WrapperComponent<P, S>

Type parameters

  • P

  • S

Hierarchy

Index

Constructors

constructor

Properties

Optional _children

_children: IComponentChild[]

react render 16 多node支持

Optional _component

子组件

_dirty

_dirty: boolean

是否加入更新队列

Optional _disable

_disable: undefined | false | true

是否停用

Optional _emitComponent

_emitComponent: Component<any, any>

模拟vue.emit用的上下文保存

Optional _key

_key: undefined | string

当前组件的key用于复用

Optional _nextVDom

_nextVDom: IVDom

被移除时的vdom缓存

Optional _parentComponent

_parentComponent: Component<IBaseProps, IKeyValue>

父组件

Optional _prevContext

_prevContext: IKeyValue

上一次的上下文

Optional _prevProps

_prevProps: PropsType

上一次的属性

Optional _prevState

_prevState: StateType

上一次的状态

Optional _ref

_ref: function | IRefObject

react标准用于设置component实例

Optional _renderCallbacks

_renderCallbacks: Array<function>

render 执行完后的回调队列

Optional _vdom

_vdom: IVDom

组件挂载后的vdom

Optional base

base: Node | Element | Text | null

context

context: IKeyValue

组件上下文,由父组件传递

Optional isFunctionComponent

isFunctionComponent: undefined | false | true

Optional name

name: undefined | string

自定义组件名

props

props: P

由父级组件传递的状态,不可修改

state

state: S

当前组件的状态,可以修改

Static Optional defaultProps

defaultProps: IKeyValue

默认props

Methods

Optional componentDidMount

  • componentDidMount(): void

Optional componentDidUpdate

  • componentDidUpdate(previousProps: P, previousState: S, snapshot: any, previousContext: IKeyValue): void
  • 在 render() 之后

    Parameters

    • previousProps: P
    • previousState: S
    • snapshot: any
    • previousContext: IKeyValue

    Returns void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

  • componentWillReceiveProps(nextProps: P, nextContext: IKeyValue): void
  • 在新的 props 被接受之前 Use static getDerivedStateFromProps() instead

    deprecated

    Parameters

    Returns void

Optional componentWillUnmount

  • componentWillUnmount(): void

Optional componentWillUpdate

  • componentWillUpdate(nextProps: P, nextState: S, nextContext: IKeyValue): void
  • 在 render() 之前,与 shouldComponentUpdate 互斥

    deprecated

    Parameters

    • nextProps: P
    • nextState: S
    • nextContext: IKeyValue

    Returns void

forceUpdate

  • forceUpdate(callback?: undefined | function): void
  • 手动的同步更新dom

    Parameters

    • Optional callback: undefined | function

      回调

    Returns void

getChildContext

  • getChildContext(): any

Optional getSnapshotBeforeUpdate

  • getSnapshotBeforeUpdate(previousProps: P, previousState: S, previousContext: IKeyValue): any

render

  • render(): undefined | null | string | number | false | true | void | VNode
  • Returns undefined | null | string | number | false | true | void | VNode

setState

  • setState(state: function | S, callback?: undefined | function): void
  • 设置state并通过enqueueRender异步更新dom

    Parameters

    • state: function | S

      对象或方法

    • Optional callback: undefined | function

      render执行完后的回调。

    Returns void

Optional shouldComponentUpdate

  • shouldComponentUpdate(nextProps: P, nextState: S, nextContext: IKeyValue): boolean
  • 在 render() 之前. 若返回 false,则跳过 render,与 componentWillUpdate 互斥

    Parameters

    • nextProps: P
    • nextState: S
    • nextContext: IKeyValue

    Returns boolean

Static Optional getDerivedStateFromProps

Generated using TypeDoc