-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing a React class as a prop no longer works in 0.13.* #3652
Comments
This doesn't seem intentional. I also can't repro in master. If we can track down what fixed this, it might be worth backporting into 0.13. cc @sebmarkbage, @spicyj |
This might have something to do with the binding itself. We used to effectively call If that is the problem, then this should still work in the production build, if no polyfill overrides |
Actually, this particular issue is probably more related to #3638 but there might be secondary issues with this pattern after that. |
For posterity, never ever do: render: function() {
var tmpl = React.createClass({
render: function() {
return <p>{this.props.data}</p>;
}
});
return (
<MyComponent
template={tmpl}
/>
);
} You're creating a new class every render which is slow and doesn't reconcile. |
To be clear, you can do this instead: var Template = React.createClass({
render: function() {
return <p>{this.props.data}</p>;
}
});
var App = React.createClass({
render: function() {
return <MyComponent template={Template} />;
}
}); |
This is fixed by #3638 |
@spicyj Your solution worked for me, but I have a question. In case I have it as a class, I run it as The question is - should I check the type of Thanks! |
If |
Hi,
I'm trying to run the following code using the latest version of React:
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
'srender
method to this fixes the issue:The text was updated successfully, but these errors were encountered: