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

[HOLD for payment 2023-05-05] [HOLD for payment 2023-04-20] [$1000] Text strings must be rendered within a <Text> component #16683

Closed
luacmartins opened this issue Mar 29, 2023 · 52 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@luacmartins
Copy link
Contributor

luacmartins commented Mar 29, 2023

Problem

Coming from Firebase Crashlytics, there are several non-fatal exceptions for Text strings must be rendered within a <Text> component. in v1.2.91. We should fix these.

Why is this important

Guarantees App stability

Solution

Find a way to reproduce the exception and prevent text nodes from being rendered outside of a <Text> component. I suspect that the exception is coming from this line, although I couldn't reproduce the issue.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ef3651f57da6d5c9
  • Upwork Job ID: 1641170623381450752
  • Last Price Increase: 2023-03-29
@luacmartins luacmartins added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 29, 2023
@luacmartins luacmartins self-assigned this Mar 29, 2023
@MelvinBot
Copy link

Triggered auto assignment to @miljakljajic (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@MelvinBot
Copy link

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@luacmartins luacmartins added the External Added to denote the issue can be worked on by a contributor label Mar 29, 2023
@melvin-bot melvin-bot bot changed the title Text strings must be rendered within a <Text> component [$1000] Text strings must be rendered within a <Text> component Mar 29, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~01ef3651f57da6d5c9

@MelvinBot
Copy link

Current assignee @miljakljajic is eligible for the External assigner, not assigning anyone new.

@MelvinBot
Copy link

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 29, 2023
@MelvinBot
Copy link

Current assignee @luacmartins is eligible for the External assigner, not assigning anyone new.

@allroundexperts
Copy link
Contributor

@luacmartins Is it possible to share the Crashlytics logs?

@luacmartins
Copy link
Contributor Author

luacmartins commented Mar 29, 2023

Stack trace:

Non-fatal Exception: io.invertase.firebase.crashlytics.JavaScriptError: Text strings must be rendered within a <Text> component.
       at .completeWork(address at index.android.bundle:1:182980)
       at .completeUnitOfWork(address at index.android.bundle:1:197038)
       at .performUnitOfWork(address at index.android.bundle:1:196882)
       at .workLoopSync(address at index.android.bundle:1:196703)
       at .renderRootSync(address at index.android.bundle:1:196587)
       at .performSyncWorkOnRoot(address at index.android.bundle:1:194006)
       at .flushSyncCallbacks(address at index.android.bundle:1:158416)
       at .batchedUpdatesImpl(address at index.android.bundle:1:210783)
       at .batchedUpdates(address at index.android.bundle:1:151205)
       at ._receiveRootNodeIDEvent(address at index.android.bundle:1:151478)
       at .receiveEvent(address at index.android.bundle:1:205242)
       at .apply((native):0:0)
       at .__callFunction(address at index.android.bundle:1:133673)
       at .anonymous(address at index.android.bundle:1:132077)
       at .__guard(address at index.android.bundle:1:133030)
       at .callFunctionReturnFlushedQueue(address at index.android.bundle:1:132035)

Logs:

errorInfo: {"componentStack":"\n    in RCTView\n    in Unknown\n    in ImageView\n    in Unknown\n    in AttachmentView\n    in Unknown\n    in RCTView\n    in Unknown\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in Carousel\n    in RCTView\n    in Unknown\n    in AttachmentCarousel\n    in withOnyx(AttachmentCarousel)\n    in Unknown\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in KeyboardAvoidingView\n    in KeyboardAvoidingView\n    in RCTView\n    in Unknown\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in withAnimatable(View)\n    in RCTView\n    in Unknown\n    in VirtualizedListContextResetter\n    in RCTModalHostView\n    in Modal\n    in ReactNativeModal\n    in BaseModal\n    in Unknown\n    in Modal\n    in Unknown\n    in AttachmentModal\n    in Unknown\n    in Unknown\n    in ImageRenderer\n    in MemoizedTNodeRenderer\n    in TNodeChildrenRenderer\n    in RCTView\n    in Unknown\n    in MemoizedTNodeRenderer\n    in TNodeChildrenRenderer\n    in RCTView\n    in Unknown\n    in MemoizedTNodeRenderer\n    in TNodeChildrenRenderer\n    in RCTView\n    in Unknown\n    in MemoizedTNodeRenderer\n    in Unknown\n    in RenderTTree\n    in SourceLoaderInline\n    in RawSourceLoader\n    in RenderHtmlSource\n    in RenderHTML\n    in ReportActionItemFragment\n    in Unknown\n    in Unknown\n    in RCTView\n    in Unknown\n    in ReportActionItemMessage\n    in Unknown\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in ReportActionItemGrouped\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in OfflineWithFeedback\n    in Unknown\n    in Unknown\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in Hoverable\n    in RCTView\n    in Unknown\n    in Pressable\n    in PressableWithSecondaryInteraction\n    in Unknown\n    in ReportActionItem\n    in Unknown\n    in Unknown\n    in Unknown\n    in Unknown\n    in Unknown\n    in RCTView\n    in Unknown\n    in InvertedCell\n    in VirtualizedListCellContextProvider\n    in CellRenderer\n    in RCTView\n    in Unknown\n    in RCTScrollView\n    in ScrollView\n    in ScrollView\n    in VirtualizedListContextProvider\n    in VirtualizedList\n    in FlatList\n    in BaseInvertedFlatList\n    in Unknown\n    in Unknown\n    in RCTView\n    in Unknown\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in ReportActionsList\n    in Unknown\n    in Unknown\n    in Unknown\n    in Unknown\n    in withDrawerState(withWindowDimensions(withLocalize(withPersonalDetails(withNetwork(ReportActionsList)))))\n    in Unknown\n    in ReportActionsView\n    in Unknown\n    in Unknown\n    in Unknown\n    in RCTView\n    in Unknown\n    in FullPageNotFoundView\n    in Unknown\n    in Suspender\n    in Suspense\n    in Freeze\n    in RCTView\n    in Unknown\n    in KeyboardAvoidingView\n    in RCTView\n    in Unknown\n    in SafeAreaConsumer\n    in ScreenWrapper\n    in Unknown\n    in withOnyx(withNetwork(ScreenWrapper))\n    in Unknown\n    in Unknown\n    in Unknown\n    in withNavigation(withWindowDimensions(withKeyboardState(Component)))\n    in Unknown\n    in ReportScreen\n    in withOnyx(ReportScreen)\n    in Unknown\n    in Unknown\n    in withDrawerState(withNetwork(Component))\n    in Unknown\n    in Unknown\n    in Unknown\n    in WithViewportOffsetTop(withLocalize(withWindowDimensions(Component)))\n    in Unknown\n    in StaticContainer\n    in EnsureSingleNavigator\n    in SceneView\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in Background\n    in Screen\n    in RNSScreen\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in Suspender\n    in Suspense\n    in Freeze\n    in DelayedFreeze\n    in InnerScreen\n    in Screen\n    in MaybeScreen\n    in RNSScreenContainer\n    in ScreenContainer\n    in MaybeScreenContainer\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in AnimatedComponent(View)\n    in Unknown\n    in RCTView\n    in Unknown\n    in AnimatedComponent(View)\n    in Unknown\n    in Wrap\n    in AnimatedComponent(Wrap)\n    in Unknown\n    in GestureDetector\n    in Drawer\n    in DrawerViewBase\n    in RNGestureHandlerRootView\n    in GestureHandlerRootView\n    in RCTView\n    in Unknown\n    in SafeAreaProviderCompat\n    in DrawerView\n    in PreventRemoveProvider\n    in NavigationContent\n    in Unknown\n    in DrawerNavigator\n    in BaseDrawerNavigator\n    in Unknown\n    in MainDrawerNavigator\n    in withOnyx(MainDrawerNavigator)\n    in Unknown\n    in StaticContainer\n    in EnsureSingleNavigator\n    in SceneView\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in CardSheet\n    in RCTView\n    in Unknown\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in PanGestureHandler\n    in PanGestureHandler\n    in RCTView\n    in Unknown\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in RCTView\n    in Unknown\n    in Card\n    in CardContainer\n    in RNSScreen\n    in AnimatedComponent\n    in AnimatedComponentWrapper\n    in Suspender\n    in Suspense\n    in Freeze\n    in DelayedFreeze\n    in InnerScreen\n    in Screen\n    in MaybeScreen\n    in RNSScreenContainer\n    in ScreenContainer\n    in MaybeScreenContainer\n    in RCTView\n    in Unknown\n    in Background\n    in CardStack\n    in RCTView\n    in Unknown\n    in SafeAreaProviderCompat\n    in RNGestureHandlerRootView\n    in GestureHandlerRootView\n    in StackView\n    in CustomRootStackNavigator\n    in AuthScreens\n    in withOnyx(AuthScreens)\n    in Unknown\n    in Unknown\n    in AppNavigator\n    in EnsureSingleNavigator\n    in BaseNavigationContainer\n    in ThemeProvider\n    in NavigationContainerInner\n    in NavigationRoot\n    in DeeplinkWrapper\n    in Expensify\n    in withOnyx(Expensify)\n    in Unknown\n    in Unknown\n    in BaseErrorBoundary\n    in KeyboardStateProvider\n    in WindowDimensionsProvider\n    in RenderersPropsProvider\n    in ListStyleSpecsProvider\n    in SharedPropsProvider\n    in RenderRegistryProvider\n    in RenderHTMLConfigProvider\n    in TRenderEngineProvider\n    in BaseHTMLEngineProvider\n    in HTMLEngineProvider\n    in LocaleContextProvider\n    in withOnyx(LocaleContextProvider)\n    in Unknown\n    in WithCurrentUserPersonalDetails(Component)\n    in Unknown\n    in withOnyx(Component)\n    in Unknown\n    in _default\n    in PortalProviderComponent\n    in RNCSafeAreaProvider\n    in SafeAreaProvider\n    in BetasProvider\n    in withOnyx(BetasProvider)\n    in Unknown\n    in Private_blockedFromConciergeProvider\n    in withOnyx(Private_blockedFromConciergeProvider)\n    in Unknown\n    in CurrentDateProvider\n    in withOnyx(CurrentDateProvider)\n    in Unknown\n    in ReportActionsDrafts_Provider\n    in withOnyx(ReportActionsDrafts_Provider)\n    in Unknown\n    in PersonalDetailsProvider\n    in withOnyx(PersonalDetailsProvider)\n    in Unknown\n    in NetworkProvider\n    in withOnyx(NetworkProvider)\n    in Unknown\n    in ComposeProviders\n    in OnyxProvider\n    in ComposeProviders\n    in RNGestureHandlerRootView\n    in GestureHandlerRootView\n    in App\n    in RCTView\n    in Unknown\n    in RCTView\n    in Unknown\n    in AppContainer"}

@MelvinBot
Copy link

Looks like something related to react-navigation may have been mentioned in this issue discussion.

As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.

Feel free to drop a note in #expensify-open-source with any questions.

@situchan
Copy link
Contributor

I believe this crash came from attachment modal which was a recent regression and now fixed.
#16636

@alexxxwork
Copy link
Contributor

alexxxwork commented Mar 29, 2023

Found this
https://stackoverflow.com/questions/52368342/invariant-violation-text-strings-must-be-rendered-within-a-text-component

So it seems we should look for all string && { code } blocks and fix them

Change ALL OF YOUR LOGICAL CONDITIONAL RENDERS into ternary renditions.

@alexxxwork
Copy link
Contributor

alexxxwork commented Mar 29, 2023

@luacmartins if these errors are new and should've appeared after recent changes in staging here are potential problems:

if (this.props.isDisabled) {
return (
<View>
{this.props.label && (
<Text style={[styles.textLabelSupporting, styles.mb1]} numberOfLines={1}>
{this.props.label}
</Text>
)}
<Text numberOfLines={1}>
{this.props.value}
</Text>
{this.props.hintText
&& (
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.hintText}
</Text>
)}
</View>

and

{this.props.hintText
&& (
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.hintText}
</Text>
)}

we shouldn't use this.props.label && and this.props.hintText &&

these are coming from this PR #16449

@situchan
Copy link
Contributor

@alexxxwork nope, this happened on iOS as well.
image

@luacmartins
Copy link
Contributor Author

It seems like the exceptions haven't happened on v1.2.92-0, which means it could be related to this deploy blocker. That being said, I do think that we should update all instances of the string && component pattern.

Please post a full proposal that addresses all instances of this pattern in App.

@praveen-ix
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

Text strings must be rendered within a component.

What is the root cause of that problem?

The possible root causes of the issue are as follows: -

  1. Use of Logical AND (&&) operator for the condition rendering inside the View element.
  2. Functional Component returns string only.
  3. Use of the string outside the Text element.
  4. Use of Terminate (;) operator inside the View element.

What changes do you think we should make in order to solve the problem?

The possible solutions to the issue are as follows: -

  1. Use the Ternary Operator instead of the Logical AND (&&) operator for condition view rendering.
  2. Functional Component should always return React Native elements.
  3. Always use string within the Text element.
  4. Do not use the Terminate (;) operator and if-else condition with curly braces inside the View element.

What alternative solutions did you explore? (Optional)

NA

@alexxxwork
Copy link
Contributor

alexxxwork commented Mar 30, 2023

Please post a full proposal that addresses all instances of this pattern in App.

@luacmartins I believe these are all cases now

Proposal

Please re-state the problem that we are trying to solve in this issue.

We get Text strings must be rendered within a <Text> component error

What is the root cause of that problem?

We need to search for pattern string && JSX to eliminate such cases

What changes do you think we should make in order to solve the problem?

we need to fix this (replace with Boolean(*), add to PropTypes):

List of files to fix

if (this.props.isDisabled) {
return (
<View>
{this.props.label && (
<Text style={[styles.textLabelSupporting, styles.mb1]} numberOfLines={1}>
{this.props.label}
</Text>
)}
<Text numberOfLines={1}>
{this.props.value}
</Text>
{this.props.hintText
&& (
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.hintText}
</Text>
)}
</View>

{this.props.hintText
&& (
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.hintText}
</Text>
)}

<View style={styles.imageModalImageCenterContainer}>
{this.props.reportID ? (
<AttachmentCarousel
reportID={this.props.reportID}
onNavigate={this.onNavigate}
source={this.props.source}
onToggleKeyboard={this.updateConfirmButtonVisibility}
/>
) : this.state.source && this.state.shouldLoadAttachment && (
<AttachmentView
source={source}
isAuthTokenRequired={this.props.isAuthTokenRequired}
file={this.state.file}
onToggleKeyboard={this.updateConfirmButtonVisibility}
/>
)}
</View>
{/* If we have an onConfirm method show a confirmation button */}
{this.props.onConfirm && (
<SafeAreaConsumer>
{({safeAreaPaddingBottomStyle}) => (
<Animated.View style={[StyleUtils.fade(this.state.confirmButtonFadeAnimation), safeAreaPaddingBottomStyle]}>
<Button
success
style={[styles.buttonConfirm, this.props.isSmallScreenWidth ? {} : styles.attachmentButtonBigScreen]}
textStyles={[styles.buttonConfirmText]}
text={this.props.translate('common.send')}
onPress={this.submitAndClose}
disabled={this.state.isConfirmButtonDisabled}
pressOnEnter
/>
</Animated.View>
)}
</SafeAreaConsumer>
)}

{props.icon && (

{props.badgeText && (

{this.props.option.customIcon && (

{props.label && (
<Text style={[styles.ml1]}>
{props.label}
</Text>
)}
{LabelComponent && (<LabelComponent />)}

{props.icon && <Icon src={props.icon} height={68} width={68} />}
{IconComponent && <IconComponent />}
</View>
</View>
<View style={[styles.w100]}>
{props.children}
</View>
<View style={[styles.w100]}>
{props.menuItems && <MenuItemList menuItems={props.menuItems} />}

{this.state.containerHeight && (
(this could be the cause of the crashalytics crash)

{props.shouldShowPendingConversionMessage && (
(not in proptypes)

{this.props.isSmallScreenWidth && (
(not in proptypes)

{this.props.multiline && <View style={styles.textInputLabelBackground} pointerEvents="none" />}
(not in proptypes)

{this.props.secureTextEntry && (
(not in proptypes)

{!this.props.secureTextEntry && this.props.icon && (

{this.shouldShowRequestCodeLink() && codeRequestedErrors
&& (
<Text style={[styles.textDanger, styles.validateCodeMessage]}>
<br />
<br />
{codeRequestedErrors}
</Text>
)}
{this.shouldShowRequestCodeLink() && codeRequestedMessage

{details.displayName && (

{linkedWorkspace && (

{this.props.report.visibility && (
(not in proptypes)

section.subTitle
&& (
<Text style={[styles.textMicroSupporting, styles.mt1]}>
{section.subTitle}
</Text>
)
}
</View>
<View style={[styles.flex1, styles.termsCenterRight]}>
<Text style={[styles.textStrong, styles.textAlignRight]}>
{section.rightText}
</Text>
{
section.subRightText
&& (

{this.props.accountManagerReportID && ReportUtils.isConciergeChatReport(this.props.report) && this.state.isBannerVisible && (

{this.props.isComposerFullSize && (
(not in proptypes)

{this.state.isDraggingOver && <ReportDropUI />}
(not in state in constructor)

{props.fragment.isEdited && (
(not in proptypes)

{inputValues.hasOtherBeneficialOwners && (

{plaidDesktopMessage && (

{props.user.isCheckingDomain && (
(not in proptypes)

{this.props.currentUserPersonalDetails.displayName && (

{this.props.account && !_.isEmpty(this.props.account.errors) && (

{showResendValidationForm && <ResendValidationForm />}

{this.props.account && !_.isEmpty(this.props.account.errors) && (

{props.user.isCheckingDomain && (

{pastedFile && (

@luacmartins
Copy link
Contributor Author

@alexxxwork your proposal looks good.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 31, 2023
@MelvinBot
Copy link

📣 @alexxxwork You have been assigned to this job by @luacmartins!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@mananjadhav
Copy link
Collaborator

@luacmartins @aldo-expensify @miljakljajic I've posted a comment on all the PRs so that the contributors are aware about this in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Apr 28, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-04-20] [$1000] Text strings must be rendered within a <Text> component [HOLD for payment 2023-05-05] [HOLD for payment 2023-04-20] [$1000] Text strings must be rendered within a <Text> component Apr 28, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 28, 2023
@MelvinBot
Copy link

Reviewing label has been removed, please complete the "BugZero Checklist".

@MelvinBot
Copy link

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.7-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-05-05. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mananjadhav] The PR that introduced the bug has been identified. Link to the PR:
  • [@mananjadhav] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@mananjadhav] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@mananjadhav] Determine if we should create a regression test for this bug.
  • [@mananjadhav] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@miljakljajic] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@mananjadhav
Copy link
Collaborator

I think we're good to close this one out? @miljakljajic the second checklist is not needed. We merged a PR to update the checklist.

@miljakljajic
Copy link
Contributor

Makes sense, closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
None yet
Development

No branches or pull requests

9 participants