Make hotloading and forceUpdate work (#164)

This commit is contained in:
Gustav Hansen 2018-07-27 19:09:10 -04:00 committed by GitHub
parent 77da61bb19
commit b30c828b95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import {
Group,
Window,
Slider,
Root,
} from './';
import { Menu } from '../';
import {
@ -71,8 +72,18 @@ class DesktopComponent {
}
removeChild(child) {
if (this.exists(child.children)) {
// we recursively remove all children
child.children.forEach(function(w) {
child.removeChild(w);
});
}
// remove it, and destroy it
if (this.exists(this.element.setChild)) {
if (this instanceof Root) {
// root doesn't have any remove method
} else if (typeof child === 'string') {
// strings don't have remove methods either
} else if (this.exists(this.element.setChild)) {
// if it can only have one child, we don't need to "de-render" it
} else if (this.exists(this.element.deleteAt)) {
// if it can have multiple ex. VerticalBox

View file

@ -73,6 +73,7 @@ const DesktopRenderer = Reconciler({
if (parentInstance.appendChild) {
parentInstance.appendChild(child);
}
if (typeof child.render === 'function') child.render(parentInstance); // we just added a new child, so we want to render it
},
removeChild(parentInstance, child) {

View file

@ -16,7 +16,7 @@ function render(element) {
// Schedules a top level update with current fiber and a priority level (depending upon the context)
DesktopRenderer.updateContainer(element, node, null);
ROOT_NODE.render();
//ROOT_NODE.render();
}
export default render;