feat(android): warn when layout child limits are exceeded#228
Open
V3RON wants to merge 2 commits into
Open
Conversation
Adds a dev-only validate hook to createVoltraComponent, invoked by the renderer once children are fully flattened (fragments inlined, nulls dropped). AndroidColumn and AndroidRow use it to warn when more than 10 direct children are rendered, matching the Jetpack Glance limit. Docs updated with the limit on the layout components page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
This PR adds a dev-only
validatehook for Voltra components and uses it to warn when AndroidColumnorRowreceive more than 10 direct children — the hard limit imposed by Jetpack Glance, which silently truncates anything beyond it. Until now, exceeding the limit produced no feedback at all: the widget just dropped children at runtime with no hint as to why.How does it work?
createVoltraComponentaccepts a new optionalvalidatecallback. It is stored on the component and invoked by the renderer — not at element creation time, where children are still raw JSX (fragments, arrays, conditionals), but at node-assembly time, once children have been recursively rendered and fully flattened. That means the count the validator sees is exactly the number of children the native side will receive.The hook only runs in development — gated on
__DEV__in Metro bundles andprocess.env.NODE_ENVin Node.js (the renderer runs in both) — and never affects the rendered JSON.ColumnandRownow warn past 10 children, and the layout components docs mention the limit with a pointer toLazyColumnfor larger collections.Why is this useful?
validateoncreateVoltraComponent), so future Glance/WidgetKit limits can be enforced the same way.Closes #220