local h=script.Parent.Parent local C=require(h.Fusion)local A=C.New local t=C.Value local B=C.Observer local E=C.Children local function n(h)local C=t(nil);(B(h.source.serving.view)):onChange(function()if h.preRender then h.preRender()end if typeof(C:get())=="\073\110\115\116\097\110\099\101"then(C:get()):Destroy()end C:set((h.source.serving.view:get())(h.source,h.source.serving))if h.postRender then h.postRender()end end)return(A("\070\114\097\109\101"))({BackgroundTransparency=1;Size=UDim2.fromScale(1,1),[E]=C})end return n
local Packages = script.Parent.Parent
local Fusion = require(Packages.Fusion)

local New = Fusion.New
local Value = Fusion.Value
local Observer = Fusion.Observer
local Children = Fusion.Children

local function Canvas(props)
    -- Fusion.Computed lacks destructor function atm, will switch to Fusion.Computed implementation in the future
    local children = Value(nil)
    Observer(props.source.serving.view):onChange(function()
        if props.preRender then
            props.preRender()
        end
        -- Fusion.Value is not equipped with destructor function, must be cleaned up manually for now
        if typeof(children:get()) == "Instance" then
            children:get():Destroy()
        end
        children:set(props.source.serving.view:get()(props.source, props.source.serving))
        if props.postRender then
            props.postRender()
        end
    end)

    return New "Frame" {
        BackgroundTransparency = 1,
        Size = UDim2.fromScale(1, 1),

        [Children] = children
    }
end

return Canvas
