fix: stop leaking empty strings into Views - #56
Merged
Merged
Conversation
Conditions like {error && <Button/>} render "" when error is the empty
string. React Native Web rejects bare strings inside a View and logs
"Unexpected text node: . A text node cannot be a child of a <View>."
(the "." is the end of the message; the text node itself is empty).
The error states start as "", so AgentStatus and the chat screen log
this on every render; a pass through Chat, Activity, Ideas, Goals and
Apps logged 13 of them.
Coerce the string-valued conditions with !! so nothing renders when
they are empty. What is shown when they are non-empty is unchanged.
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 changed
The web app logs this error repeatedly:
The "." is the end of React Native Web's message; the text node itself is an empty string. Conditions like
{error && <Button …/>}render""whenerroris the empty string, and the error states start asuseState(""). SoAgentStatus, which is on every screen, and the chat screen log it on every render.String-valued conditions now use
!!, so nothing renders when the string is empty. What shows when the string is non-empty is unchanged. That covers 13 sites in 7 files:errorstates, and optional strings such astask.result,monitor.lastValue,action.result,previewUrl,snapshot.message, andSheet/LinkRowsubtitle/detail.Verification
main: 13 warnings.Views with string children found theChatScreenscroll content onmain, and nothing on this branch.pnpm typecheckpasses. Biome reports no issues for the changed files.pnpm test: 161 passed, 1 failed. The failure isDocker subprocess uses literal argv…, which fails on Windows with or without this change.Integration limits
<Text>can throw "Text strings must be rendered within a component", so this should also remove that risk. I did not run a native build.lint/suspicious/noLeakedRendercatches this pattern. It is not enabled, because it cannot see types: it flags 37 sites, mostly booleans that are already safe. I left enabling it to maintainers.