Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create children until after we check if element is wrapped by a component #1

Closed
Corecii opened this issue May 22, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Corecii
Copy link
Owner

Corecii commented May 22, 2022

local children = {}
for name, child in pairs(template.children) do
children[name] = elementFromTemplate(Roact, child, callSelectors, nameSelectors)
end
local props = applySelectors(Roact, template, children, callSelectors, nameSelectors)
local element
if props[Wrap] then
element = Roact.createElement(props[Wrap], {
template = RoactTemplate.componentFromTemplate(Roact, template),
})
else
element = Roact.createElement(template.class, props, children)
end

Currently if an element is wrapped with a component it creates all of its children just to throw them away.

Creating children first is only necessary because ChangesCallback mutates the existing props and children dicts. Children should not be read. Props has reasonable use-cases for reading e.g. darkening default background color. If we have ChangesCallback return the new props it wants to set then we preserve all existing functionality and we can compute children after ChangesCallback is ran. This would allow Wrapped elements to not compute their children until their template is created.

@Corecii Corecii added the enhancement New feature or request label May 22, 2022
@Corecii Corecii self-assigned this May 22, 2022
@Corecii Corecii closed this as completed May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant