Closed
Description
Hi,
I'm trying to run the following code using the latest version of React:
var MyComponent = React.createClass({
render: function() {
return (
<div>
<this.props.template
data='test'
/>
</div>
);
}
});
var App = React.createClass({
render: function() {
return (
<MyComponent
template={this.template}
/>
);
},
template: React.createClass({
render: function() {
return <p>{this.props.data}</p>;
}
})
});
React.render(<App />, document.body);
However, an error is thrown once the code is ran: "Uncaught TypeError: Cannot read property 'mountComponent' of undefined"
The above code functions as expected in React 0.12.2. Someone figured out this is due to a change in the way React 0.13.* classes autobinds all of its methods. Therefore, changing App
's render
method to this fixes the issue:
render: function() {
var tmpl = React.createClass({
render: function() {
return <p>{this.props.data}</p>;
}
});
return (
<MyComponent
template={tmpl}
/>
);
}
Metadata
Metadata
Assignees
Labels
No labels