Skip to content

Is setting the defaultProps correct in this way? #14428

@ldwonday

Description

@ldwonday
export default class extends PureComponent {
...
  render() {
    const { size = 24, content, mode, color = 'rgb(97, 144, 232)', height = '160px' } = this.props
    return (
      <div className="loading" style={{ minHeight: height, height }}>
        <div className="inner">
          <div className="icon" style={{ width: `${size}px`, height: `${size}px` }}>
            <Iconfont size={size} color={color} type="loading" />
          </div>
          {content && <div className="content">{content}</div>}
        </div>
      </div>
    )
  }
}

Set the defaultProps with ES6 destructuring. If the way is incorrect, why? Does it has any side effect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions