Support changing ClassName in Reconciler.diff

This commit is contained in:
Lucien Greathouse
2021-01-16 18:26:30 -07:00
parent 5989ab3b85
commit cc4f4df4f9

View File

@@ -52,8 +52,9 @@ local function diff(instanceMap, virtualInstances, rootId)
invariant("Cannot diff an instance not present in InstanceMap\nID: {}", id) invariant("Cannot diff an instance not present in InstanceMap\nID: {}", id)
end end
local changedClassName = nil
if virtualInstance.ClassName ~= instance.ClassName then if virtualInstance.ClassName ~= instance.ClassName then
error("unimplemented: support changing ClassName") changedClassName = virtualInstance.ClassName
end end
local changedName = nil local changedName = nil
@@ -89,11 +90,11 @@ local function diff(instanceMap, virtualInstances, rootId)
end end
end end
if changedName ~= nil or not isEmpty(changedProperties) then if changedName ~= nil or changedClassName ~= nil or not isEmpty(changedProperties) then
table.insert(patch.updated, { table.insert(patch.updated, {
id = id, id = id,
changedName = changedName, changedName = changedName,
changedClassName = nil, changedClassName = changedClassName,
changedProperties = changedProperties, changedProperties = changedProperties,
changedMetadata = nil, changedMetadata = nil,
}) })