import extendReactClass from './extendReactClass';
import wrapStatelessFunction from './wrapStatelessFunction';

let decoratorConstructor,
    functionConstructor;

/**
 * When used as a function.
 *
 * @param {Function} Component
 * @param {Object} defaultStyles CSS Modules class map.
 * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
 * @return {Function}
 */
functionConstructor = (Component, defaultStyles, options) => {
    let decoratedClass;

    decoratedClass = Component.isReactClass ?
        extendReactClass(Component, defaultStyles, options) :
        wrapStatelessFunction(Component, defaultStyles, options);

    if (Component.displayName) {
        decoratedClass.displayName = Component.displayName;
    } else {
        decoratedClass.displayName = Component.name;
    }

    return decoratedClass;
};

/**
 * When used as a ES7 decorator.
 *
 * @param {Object} defaultStyles CSS Modules class map.
 * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
 * @return {Function}
 */
decoratorConstructor = (defaultStyles, options) => {
    return (Component) => {
        return functionConstructor(Component, defaultStyles, options);
    };
};

export default (...args) => {
    if (typeof args[0] === 'function') {
        return functionConstructor(args[0], args[1], args[2]);
    } else {
        return decoratorConstructor(args[0], args[1]);
    }
};

@@ -155,18 +155,319 @@
 structor
+,%0A    isReactComponent;%0A%0A/**%0A * Determines if the given object has the signature of a class that inherits React.Component.%0A *%0A * @param %7B*%7D Component%0A * @return %7BBoolean%7D%0A */%0AisReactComponent = (Component) =%3E %7B%0A    return 'prototype' in Component && typeof Component.prototype.render === 'function';%0A%7D
 ;%0A
-
 %0A/**%0A * 
@@ -789,57 +789,67 @@
     
-decoratedClass = Component.isReactClass ?%0A       
+if (isReactComponent(Component)) %7B%0A        decoratedClass =
  ext
@@ -900,18 +900,47 @@
 ons)
- :%0A       
+;%0A    %7D else %7B%0A        decoratedClass =
  wra
@@ -993,16 +993,22 @@
 ptions);
+%0A    %7D
 %0A%0A    if

A smarter way of determining of class is a React.Component. https://github.com/gajus/react-css-modules/pull/41