function createApp(rootComponent) {
return {
mount(selector) {
const container = document.querySelector(selector)
let oldVNode;
let isMounted = false;
watchEffect(function() {
if (!isMounted) {
oldVNode = rootComponent.render()
mount(oldVNode, container)
isMounted = true;
} else {
const newVNode = rootComponent.render()
patch(oldVNode, newVNode);
oldVNode = newVNode
}
})
}
}
}