Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use es6 class style in demo code #4878

Closed
zhangolve opened this issue Feb 15, 2017 · 8 comments
Closed

Use es6 class style in demo code #4878

zhangolve opened this issue Feb 15, 2017 · 8 comments
Assignees
Labels
📝 Documentation help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request.

Comments

@zhangolve
Copy link

2.7.1 版 Ant Design 文档:https://ant.design/docs/react/introduce-cn

文档的示例代码,针对React有状态组件分别使用了两种不同的定义组件的方式。

在大多数情况下 ,比如Modal的示例代码,采用了

const App = React.createClass({}) 

上面那样的写法。

而在steps,slider 等组件的示例代码中,又出现了

class Demo extends React.Component {}

这样的写法

我不知道出现这两种定义组件的方式的用意何在?

我当然知道这样一个庞大的项目,文档绝对不可能是一个人写成的,但还是希望能够统一一下定义组件的方式。看React的官方文档,目前官方应该是推荐使用第二种定义组件的方式的。

@benjycui
Copy link
Contributor

Agree, could you PR to update React.createClass to class extends? Thanks.

It will be better to write your issue/comment in English, so more people can understand you. And this means that more people can help you or benefit from your issue/comment.

@benjycui benjycui added 📝 Documentation help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request. labels Feb 15, 2017
@paranoidjk
Copy link
Contributor

the same as ant-design/ant-design-mobile#824

@GrayChoi
Copy link
Contributor

Let us do it.

@afc163
Copy link
Member

afc163 commented Feb 19, 2017

  • affix
  • alert
  • anchor
  • auto-complete
  • back-top
  • badge
  • breadcrumb
  • button
  • calendar
  • card
  • carousel
  • cascader
  • checkbox
  • collapse
  • date-picker
  • dropdown
  • form
  • grid
  • input
  • input-number
  • layout
  • locale-provider
  • mention
  • menu
  • message
  • modal
  • notification
  • pagination
  • popconfirm
  • popover
  • progress
  • radio
  • rate
  • select
  • slider
  • spin
  • steps
  • switch
  • table
  • tabs
  • tag
  • time-picker
  • timeline
  • tooltip
  • transfer
  • tree
  • tree-select
  • upload

Anyone could propose PR for React.createClass => React.Component and check this list after merging.

@afc163
Copy link
Member

afc163 commented Feb 20, 2017

Enable this rule: d7694d4

And run npm run lint:demo, there are only 31 errors left.

/Users/afc163/Projects/ant-design/components/menu/demo/horizontal.md
  21:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/menu/demo/sider-current.md
  24:33  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/menu/demo/sider.md
  21:33  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/menu/demo/switch-mode.md
  21:33  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/menu/demo/theme.md
  20:33  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/modal/demo/async.md
  20:32  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/modal/demo/basic.md
  19:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/modal/demo/footer.md
  25:32  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/modal/demo/locale.md
  19:42  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/modal/demo/position.md
  20:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/pagination/demo/controlled.md
  19:37  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/popconfirm/demo/dynamic-trigger.md
  19:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/popover/demo/control.md
  19:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/progress/demo/circle-dynamic.md
  20:38  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/progress/demo/dynamic.md
  20:38  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/radio/demo/disable.md
  19:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/radio/demo/radiogroup-more.md
  20:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/radio/demo/radiogroup.md
  20:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/rate/demo/text.md
  19:33  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/select/demo/combobox.md
  25:32  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/select/demo/coordinate.md
  31:31  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/select/demo/search-box.md
  57:39  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/slider/demo/icon-slider.md
  19:38  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/slider/demo/input-number.md
  19:39  error  Component should use es6 class instead of createClass  react/prefer-es6-class
  46:39  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/spin/demo/delayAndDebounce.md
  19:32  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/spin/demo/nested.md
  19:32  error  Component should use es6 class instead of createClass  react/prefer-es6-class

/Users/afc163/Projects/ant-design/components/switch/demo/disabled.md
  19:32  error  Component should use es6 class instead of createClass  react/prefer-es6-class

✖ 36 problems (36 errors, 0 warnings)

@afc163 afc163 changed the title 希望能够对文档中React 有状态组件统一定义方式 Use es6 class style in demo code Feb 20, 2017
@afc163
Copy link
Member

afc163 commented Feb 20, 2017

All done!! 🎆 🎉

Thanks everybody!!!

@minwe
Copy link
Contributor

minwe commented Feb 27, 2017

用雨燕构建时使用了 2.7.3,导致原来的应用点击 Modal 确定执行操作时出现内存泄露,降级到 2.7.2 以后恢复正常。具体原因暂时顾不上看,回头再确认一下。

@lock
Copy link

lock bot commented May 2, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📝 Documentation help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request.
Projects
None yet
Development

No branches or pull requests