From 1fc89905315ba6b5a13e78a291910296d4d7c1b1 Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Sun, 19 Feb 2017 20:27:06 +0800 Subject: [PATCH] docs: Rewrite Badge demos to ES6 component --- components/badge/demo/change.md | 34 +++++++++++++++-------------- components/badge/demo/dot.md | 18 ++++++++------- components/badge/demo/no-wrapper.md | 12 +++++----- components/badge/demo/overflow.md | 30 +++++++++++++------------ 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 400bbb23bb..a56b044b30 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -17,27 +17,29 @@ The count will be animated as it changes. import { Badge, Button, Icon, Switch } from 'antd'; const ButtonGroup = Button.Group; -const Test = React.createClass({ - getInitialState() { - return { - count: 5, - show: true, - }; - }, - increase() { +class Demo extends React.Component { + state = { + count: 5, + show: true, + } + + increase = () => { const count = this.state.count + 1; this.setState({ count }); - }, - decline() { + } + + decline = () => { let count = this.state.count - 1; if (count < 0) { count = 0; } this.setState({ count }); - }, - onChange(show) { + } + + onChange = (show) => { this.setState({ show }); - }, + } + render() { return (
@@ -62,8 +64,8 @@ const Test = React.createClass({
); - }, -}); + } +} -ReactDOM.render(, mountNode); +ReactDOM.render(, mountNode); ```` diff --git a/components/badge/demo/dot.md b/components/badge/demo/dot.md index 124d8e899f..6cee5e1569 100644 --- a/components/badge/demo/dot.md +++ b/components/badge/demo/dot.md @@ -16,14 +16,16 @@ This will simply display a red badge, without a specific count. ````jsx import { Badge, Icon } from 'antd'; -ReactDOM.render(
- - - - - Link something - -
, mountNode); +ReactDOM.render( +
+ + + + + Link something + +
+, mountNode); ````