Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
fix shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorGriffin37 committed Aug 5, 2021
1 parent bea79f7 commit 6ccce30
Showing 1 changed file with 101 additions and 101 deletions.
202 changes: 101 additions & 101 deletions src/RobloxRenderer.spec.lua
Expand Up @@ -1115,146 +1115,146 @@ return function()

reconciler.unmountVirtualNode(instance)
end)
end)

it("should never call unmount twice when tempFixUpdateChildrenReEntrancy is turned on", function()
local configValues = {
tempFixUpdateChildrenReEntrancy = true,
}

GlobalConfig.scoped(configValues, function()
local unmountCounts = {}
local unMountTracebacks = {}

local function addUnmount(id)
unmountCounts[id] = unmountCounts[id] + 1

if unMountTracebacks[id] then
print("First Traceback!")
print(unMountTracebacks[id])
print("Second Traceback!")
print(debug.traceback())
end
it("should never call unmount twice when tempFixUpdateChildrenReEntrancy is turned on", function()
local configValues = {
tempFixUpdateChildrenReEntrancy = true,
}

unMountTracebacks[id] = debug.traceback()
end
GlobalConfig.scoped(configValues, function()
local unmountCounts = {}
local unMountTracebacks = {}

local function addInit(id)
unmountCounts[id] = 0
end
local function addUnmount(id)
unmountCounts[id] = unmountCounts[id] + 1

local LowestComponent = Component:extend("LowestComponent")
function LowestComponent:init()
addInit(tostring(self))
if unMountTracebacks[id] then
print("First Traceback!")
print(unMountTracebacks[id])
print("Second Traceback!")
print(debug.traceback())
end

function LowestComponent:render()
return createElement("Frame")
end
unMountTracebacks[id] = debug.traceback()
end

function LowestComponent:didMount()
self.props.onDidMountCallback()
end
local function addInit(id)
unmountCounts[id] = 0
end

function LowestComponent:willUnmount()
addUnmount(tostring(self))
end
local LowestComponent = Component:extend("LowestComponent")
function LowestComponent:init()
addInit(tostring(self))
end

local FirstComponent = Component:extend("FirstComponent")
function FirstComponent:init()
addInit(tostring(self))
end
function LowestComponent:render()
return createElement("Frame")
end

function FirstComponent:render()
return createElement("TextLabel")
end
function LowestComponent:didMount()
self.props.onDidMountCallback()
end

function FirstComponent:willUnmount()
addUnmount(tostring(self))
end
function LowestComponent:willUnmount()
addUnmount(tostring(self))
end

local ChildComponent = Component:extend("ChildComponent")
local FirstComponent = Component:extend("FirstComponent")
function FirstComponent:init()
addInit(tostring(self))
end

function ChildComponent:init()
addInit(tostring(self))
function FirstComponent:render()
return createElement("TextLabel")
end

self:setState({
firstTime = true
})
end
function FirstComponent:willUnmount()
addUnmount(tostring(self))
end

local childCoroutine
local ChildComponent = Component:extend("ChildComponent")

function ChildComponent:render()
if self.state.firstTime then
return createElement(FirstComponent)
end
function ChildComponent:init()
addInit(tostring(self))

return createElement(LowestComponent, {
onDidMountCallback = self.props.onDidMountCallback
})
end
self:setState({
firstTime = true
})
end

function ChildComponent:didMount()
childCoroutine = coroutine.create(function()
self:setState({
firstTime = false
})
end)
end
local childCoroutine

function ChildComponent:willUnmount()
addUnmount(tostring(self))
function ChildComponent:render()
if self.state.firstTime then
return createElement(FirstComponent)
end

local ParentComponent = Component:extend("ParentComponent")
return createElement(LowestComponent, {
onDidMountCallback = self.props.onDidMountCallback
})
end

function ParentComponent:init()
function ChildComponent:didMount()
childCoroutine = coroutine.create(function()
self:setState({
count = 1
firstTime = false
})
end)
end

self.onDidMountCallback = function()
if self.state.count < 5 then
self:setState({
count = self.state.count + 1,
})
end
function ChildComponent:willUnmount()
addUnmount(tostring(self))
end

local ParentComponent = Component:extend("ParentComponent")

function ParentComponent:init()
self:setState({
count = 1
})

self.onDidMountCallback = function()
if self.state.count < 5 then
self:setState({
count = self.state.count + 1,
})
end
end
end

function ParentComponent:render()
return createElement("Frame", {
function ParentComponent:render()
return createElement("Frame", {

}, {
ChildComponent = createElement(ChildComponent, {
count = self.state.count,
onDidMountCallback = self.onDidMountCallback,
})
}, {
ChildComponent = createElement(ChildComponent, {
count = self.state.count,
onDidMountCallback = self.onDidMountCallback,
})
end
})
end

local parent = Instance.new("ScreenGui")
parent.Parent = game.CoreGui
local parent = Instance.new("ScreenGui")
parent.Parent = game.CoreGui

local tree = createElement(ParentComponent)
local tree = createElement(ParentComponent)

local hostKey = "Some Key"
local instance = reconciler.mountVirtualNode(tree, parent, hostKey)
local hostKey = "Some Key"
local instance = reconciler.mountVirtualNode(tree, parent, hostKey)

coroutine.resume(childCoroutine)
coroutine.resume(childCoroutine)

expect(#parent:GetChildren()).to.equal(1)
expect(#parent:GetChildren()).to.equal(1)

local frame = parent:GetChildren()[1]
local frame = parent:GetChildren()[1]

expect(#frame:GetChildren()).to.equal(1)
expect(#frame:GetChildren()).to.equal(1)

reconciler.unmountVirtualNode(instance)
reconciler.unmountVirtualNode(instance)

for _, value in pairs(unmountCounts) do
expect(value).to.equal(1)
end
end)
for _, value in pairs(unmountCounts) do
expect(value).to.equal(1)
end
end)
end)
end)
Expand Down

0 comments on commit 6ccce30

Please sign in to comment.