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

Components that use children get their children set to nil after any rerenders #11

Open
fewkz opened this issue Apr 17, 2023 · 1 comment
Labels
bug Something isn't working pretty important

Comments

@fewkz
Copy link
Owner

fewkz commented Apr 17, 2023

The faulty code is

froact/froact.lua

Lines 174 to 176 in c9790a0

local children = props[roact.Children]
props[roact.Children] = nil
return body(props, hooks, if children then children else blankChildren)

It sets the children to be blank after the first render, which is bad. We can fix this by removing the line that sets the props[roact.Children] to nil, but we don't really want children to be in props. Haven't quite figured out a better solution yet.
For now, to fix, you have to do this following code: local children = hooks.useMemo(function() return children end, {props}), since the children will get set correct whenever props change.

@fewkz
Copy link
Owner Author

fewkz commented Apr 18, 2023

we could store the children in a table that's weak on props, as a sort of weak cache so that we can recover the children on subsequent renders

@fewkz fewkz added bug Something isn't working pretty important labels Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pretty important
Projects
None yet
Development

No branches or pull requests

1 participant