mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-23 18:50:06 +08:00
Page:
Code convention for antd
Pages
API Naming rules
Ant Design 设计基础简版
CSS in JS 迁移指南
Code convention for antd
Collaborators
Configuration for Documentation and Demo
Cookbook
Development
Document types conventions
FAQ
Home
PR principle
PR 规范
Template for Bug Report in IE8 9
Unique Panel Component
v5 API 废弃流程
什么是最小化重现,为什么这是必需的?
老版本和beta版本文档发布流程
设计文档上传流程
轮值规则和版本发布流程
6
Code convention for antd
Sebastian Blade edited this page 2017-03-03 21:28:11 +08:00
Any component from react-component should be named with prefix Rc
.
// Good
import RcSlider from 'rc-slider';
// Bad
import Slider from 'rc-slider';
All the components of antd should use its name in documentation.
// Good
class Button extends React.Component {}
// Bad
class AntButton extends React.Component {}
This will make it more clear in developer tool.
Extends React.Component
instead of Component
// Good
import React from 'react';
class Button extends React.Component {}
// Bad
import React, { Component } from 'react';
class Button extends Component {}
Bind this
in class definition with ES6 syntax
// Good
class Button extends React.Component {
onClick = () => {}
render() {
return <button onClick={this.onClick} />
}
}
// Bad
class Button extends React.Component {
onClick() {}
render() {
return <button onClick={this.onClick.bind(this)} />
}
}
// Bad
class Button extends React.Component {
constructor(props) {
super(props);
this.onClick = this.onClick.bind(this);
}
onClick() {}
render() {
return <button onClick={this.onClick} />
}
}
Define static property in class definition
// Good
class Button extends React.Component {
static propTypes = {...}
static defaultProps = {...}
}
// Bad
class Button extends React.Component {}
Button.propTypes = {...};
Button.defaultProps = {...};
- Home
- Cookbook
- FAQ
- Template for Bug Report in IE8 9
- Contributing
- Maintaining
- Design