fewkz / froact

Wrapper around Roact & Roact Hooks to simplify UI development and add full, correct Luau typing
MIT License
3 stars 0 forks source link

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

Open fewkz opened 1 year ago

fewkz commented 1 year ago

The faulty code is https://github.com/fewkz/froact/blob/c9790a07feaea1ef6a598c0471ad8a12752251b0/froact.lua#L174-L176

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 commented 1 year ago

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