-
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
Improper 'this' context during createClass(): 0.11.1 #2183
Comments
We do different wrapping around Constructor in 0.11 than we did in 0.10 so you probably need to adjust for that. You're hacking the system in unsupported ways so I don't think we have any intention of supporting your case directly. cc @sebmarkbage in case he has anything to add / wants to reopen / think about things |
I guess the real question is: "how do you create a component programmatically (from outside React's world)"? var descriptor = React.createClass.call(React, spec)
mixinRender(spec, descriptor)
function mixinRender(spec, descriptor) {
Object.defineProperty(descriptor, 'render', {
... etc
, value: function staticRender(model, node) {
var Ctor = this(model)
var component = React.renderComponent(Ctor, node)
return Promise.resolve(component)
}
}
} This just spot-welds a render onto the descriptor, the function that expects to receive props/children during a |
Basically you can just replace the line: var Ctor = this(model); with var Ctor = React.createElement(this, model); (note that this was called |
In React 0.10, I am able to decorate the render method with a static render that returns a promise, as opposed to React's own callback implementation.
This semi-decoration worked well enough for my purposes. It returns to the caller a descriptor as I would expect.
However, following the same pattern in 0.11.1 gives me a
no property 'construct
error during the internal createClass() call.Digging around in the codebase, it just looks like a forgotten context bind.
The text was updated successfully, but these errors were encountered: