-
Notifications
You must be signed in to change notification settings - Fork 46k
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
Externally injected content with ES6 Class-based components #4087
Comments
If you really want to control the children of UIPane imperatively in that way, you can add a
(setProps in particular can be confusing because now you have multiple places in your app disagreeing about what they think the current props are.) @jimfb also has a ReactComponentRenderer wrapper class that might be helpful. Like #1711. |
@spicyj Thank you very much for the lightning reply! |
@spicyj I tried your suggestion and the class method doesn't seem to be available on the ReactElement. class UIPane extends UIView {
constructor(...args) {
super(...args);
this.state = {
children: null
};
this.setChildren = this.setChildren.bind(this);
}
componentWillUnmount() {
if (this.props.handleUnmount) {
this.props.handleUnmount();
}
}
setChildren(renderables) {
return new Promise((resolve) => {
this.setState({
children: renderables
}, resolve);
});
}
render() {
return (
<div className='ui-pane'>
{this.state.children}
</div>
);
}
} Later on, |
This should work: var uiPane = React.render(<UIPane ... />, node)
uiPane.setChildren(stuff) You'll have a component instance, not an element. You can't do anything with just an element ( |
You can also do
and then |
Yup, that's what I ended up with! Thank you.
|
I have a use case where I am creating a
UIPane
element in one place (a window manager), passing its reference to an application bootstrapper and then the application is responsible for injecting other elements into itsUIPane
.Since the
setProps
-esque methods were removed for ES6 classes, how can I accomplish this?The text was updated successfully, but these errors were encountered: