Skip to content

Getters in mixin #4450

@JAStanton

Description

@JAStanton

I want to use ES5 style getters inside of a mixin. It blows up when it comes to this line inside of ReactClass where by it invokes my getter method while it's mixing it in. This has some unexpected behavior.
https://github.com/facebook/react/blob/master/src/isomorphic/classic/class/ReactClass.js#L485

const fooMixin =  {
 componentWillMount() {
  this.myFoo = 'bar';
 }
 get foo() {
   return this.myFoo;
 }
}

const MyComponent = React.createClass({
  mixins: [fooMixin],
  render() {
    return <span>{this.foo}</span>
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions