Skip to content

Apply component spec + mixins specs deterministically #1589

Closed
@zpao

Description

@zpao

Right now we don't do this consistently, so you could have behavior that varies depending on where you put the mixins key in your class spec. That's not great.

Here's an example: http://jsfiddle.net/zpao/9sW7n/ (using master)

var Mixin = {
  componentDidMount: function() {
    console.log('Mixin');
  }
};

var CompA = React.createClass({
  mixins: [Mixin],
  componentDidMount: function() {
    console.log('CompA');
  },
  render: function() {
    return <span>A</span>;
  }
})

var CompB = React.createClass({
  componentDidMount: function() {
    console.log('CompB');
  },
  mixins: [Mixin],
  render: function() {
    return <span>B</span>;
  }
})

This outputs:

"Mixin"
"CompA"
"CompB"
"Mixin"

I think we should consistently behave like CompB (component, then mixin methods) but @yungsters disagrees. Any other opinions. @petehunt @sebmarkbage @jordwalke

Potentially interested @gaearon (once we figure out which way we go)? This is relatively contained and testable but it does take you right into core.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions