Skip to content

Commit 0103f2d

Browse files
committed
Allow ReduxComponentClasses to be used as mixins.
1 parent 16b9a4a commit 0103f2d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/applyMixin.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { assign, chain } from './util'
22
import invariant from 'invariant'
3+
import ReduxComponent from './ReduxComponent'
34

45
# Handle various special mixin keys
56
chainedKeyHandler = (spec, mixin, key, val) ->
@@ -57,6 +58,9 @@ mixinKeyHandlers = {
5758
}
5859

5960
export default baseApplyMixin = (spec, mixin) ->
61+
# Allow the use of ReduxComponentClasses as mixins
62+
if mixin?.prototype and (mixin.prototype instanceof ReduxComponent)
63+
mixin = mixin.prototype.__spec
6064
# Force mixin of submixins to happen before everything else.
6165
if mixin.mixins then mixinKeyHandlers.mixins(spec, mixin, 'mixins', mixin.mixins)
6266
# Apply this mixin

src/createClass.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default createClass = (spec) ->
3030
# inherit from ReduxComponent
3131
Constructor.prototype = new ReduxComponent
3232
Constructor.prototype.constructor = Constructor
33+
Constructor.prototype.__spec = spec
3334
# Apply spec to prototype, statics to constructor
3435
for own k,v of newSpec
3536
Constructor.prototype[k] = v

0 commit comments

Comments
 (0)