From 1b81aa8c75c5593f62ed366de00d5f29ed65f381 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sun, 20 Mar 2016 19:41:34 +0700 Subject: [PATCH] Convert Popover & Spin to ES2015 classes. --- components/popover/index.jsx | 30 +++++++++++++----------------- components/spin/index.jsx | 28 ++++++++++++---------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/components/popover/index.jsx b/components/popover/index.jsx index 44aef07df2..58dc31b6ea 100644 --- a/components/popover/index.jsx +++ b/components/popover/index.jsx @@ -5,18 +5,7 @@ import getPlacements from './placements'; const placements = getPlacements(); const prefixCls = 'ant-popover'; -const Popover = React.createClass({ - getDefaultProps() { - return { - prefixCls, - placement: 'top', - trigger: 'hover', - mouseEnterDelay: 0.1, - mouseLeaveDelay: 0.1, - overlayStyle: {} - }; - }, - +export default class Popover extends React.Component { render() { const transitionName = ({ top: 'zoom-down', @@ -42,11 +31,11 @@ const Popover = React.createClass({ {this.props.children} ); - }, + } getPopupDomNode() { return this.refs.tooltip.getPopupDomNode(); - }, + } getOverlay() { return ( @@ -57,7 +46,14 @@ const Popover = React.createClass({ ); - }, -}); + } +} -export default Popover; +Popover.defaultProps = { + prefixCls, + placement: 'top', + trigger: 'hover', + mouseEnterDelay: 0.1, + mouseLeaveDelay: 0.1, + overlayStyle: {} +}; diff --git a/components/spin/index.jsx b/components/spin/index.jsx index bb96b61d6e..8d1bdd9bbc 100644 --- a/components/spin/index.jsx +++ b/components/spin/index.jsx @@ -2,22 +2,10 @@ import React from 'react'; import classNames from 'classnames'; import { isCssAnimationSupported } from 'css-animation'; -const AntSpin = React.createClass({ - getDefaultProps() { - return { - prefixCls: 'ant-spin', - spining: true, - }; - }, - - propTypes: { - className: React.PropTypes.string, - size: React.PropTypes.oneOf(['small', 'default', 'large']), - }, - +export default class Spin extends React.Component { isNestedPattern() { return !!(this.props && this.props.children); - }, + } render() { const { className, size, prefixCls, tip } = this.props; @@ -56,6 +44,14 @@ const AntSpin = React.createClass({ } return spinElement; } -}); +} -export default AntSpin; +Spin.defaultProps = { + prefixCls: 'ant-spin', + spining: true, +}; + +Spin.propTypes = { + className: React.PropTypes.string, + size: React.PropTypes.oneOf(['small', 'default', 'large']), +};