import React from 'react';

export default ({ expandable, prefixCls, onExpand, needIndentSpaced, expanded, record }) => {
  if (expandable) {
    const expandClassName = expanded ? 'expanded' : 'collapsed';
    return (
      <span
        className={`${prefixCls}-expand-icon ${prefixCls}-${expandClassName}`}
        onClick={() => onExpand(!expanded, record)}
      />
    );
  } else if (needIndentSpaced) {
    return <span className={`${prefixCls}-expand-icon ${prefixCls}-spaced`} />;
  }
  return null;
};

import React, { PropTypes } from 'react';
import shallowequal from 'shallowequal';

const ExpandIcon = React.createClass({
  propTypes: {
    record: PropTypes.object,
    prefixCls: PropTypes.string,
    expandable: PropTypes.any,
    expanded: PropTypes.bool,
    needIndentSpaced: PropTypes.bool,
    onExpand: PropTypes.func,
  },
  shouldComponentUpdate(nextProps) {
    return !shallowequal(nextProps, this.props);
  },
  render() {
    const { expandable, prefixCls, onExpand, needIndentSpaced, expanded, record } = this.props;
    if (expandable) {
      const expandClassName = expanded ? 'expanded' : 'collapsed';
      return (
        <span
          className={`${prefixCls}-expand-icon ${prefixCls}-${expandClassName}`}
          onClick={() => onExpand(!expanded, record)}
        />
      );
    } else if (needIndentSpaced) {
      return <span className={`${prefixCls}-expand-icon ${prefixCls}-spaced`} />;
    }
    return null;
  },
});

export default ExpandIcon;

Fix returned null in stateless function in react@0.14.x
Fix returned null in stateless function in react@0.14.x

https://github.com/facebook/react/pull/5884
