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 2024-10-30] [$250] [DEV] - Console Warning: Function components cannot be given refs #50676

Closed
1 of 6 tasks
m-natarajan opened this issue Oct 11, 2024 · 23 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Oct 11, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: Dev
Reproducible in staging?: dev
Reproducible in production?: dev
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @rojiphil
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1728537899975699

Action Performed:

  1. Load/Reload the iOS App
  2. Open a chat report with messages
  3. Long press on a message to display the popover menu.

Expected Result:

The warning Function components cannot be given refs. should not come-up.

Actual Result:

The following warning is displayed:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

console-warning.mp4
Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021845992163268596085
  • Upwork Job ID: 1845992163268596085
  • Last Price Increase: 2024-10-15
  • Automatic offers:
    • hoangzinh | Reviewer | 104449083
Issue OwnerCurrent Issue Owner: @garrettmknight
@m-natarajan m-natarajan added Daily KSv2 Needs Reproduction Reproducible steps needed Bug Something is broken. Auto assigns a BugZero manager. labels Oct 11, 2024
Copy link

melvin-bot bot commented Oct 11, 2024

Triggered auto assignment to @garrettmknight (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@MelvinBot
Copy link

This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

@Shahidullah-Muffakir
Copy link
Contributor

Proposal

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

We are facing a warning message in our iOS app that says, "Function components cannot be given refs." This warning appears when users try to interact with chat messages

What is the root cause of that problem?

The root cause of this problem is that some functional components in our app are being assigned refs, but they are not set up to handle them. In React, functional components do not accept refs by default, which leads to this warning.

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

To solve this problem, we should update the functional component by wrapping it with React.forwardRef(). This will allow these components to accept and properly use refs without generating warnings.

What alternative solutions did you explore? (Optional)

@jayeshmangwani
Copy link
Contributor

Proposal

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

Encountering a console error: "Function components cannot be given refs" when long-pressing the message.

What is the root cause of that problem?

This specific issue is originating from the usage of withOnyx and wrapping it in memo on the BaseReportActionContextMenu file. We're also seeing the same error in the ReportScreen and Sidebar screens too, though those errors are coming from different files.

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

I suggest a similar approach as with this issue: we should replace withOnyx with useOnyx.

For this issue, we can focus on the BaseReportActionContextMenu and BaseKycWall files.

What alternative solutions did you explore? (Optional)

If right now we dont want to replace the usage of useOnyx instead of withOnyx then we can do use the forwardRef for BaseReportActionContextMenu like this:

function BaseReportActionContextMenu({

const BaseReportActionContextMenu = React.forwardRef(function BaseReportActionContextMenu({

@melvin-bot melvin-bot bot added the Overdue label Oct 14, 2024
@garrettmknight garrettmknight added External Added to denote the issue can be worked on by a contributor and removed Needs Reproduction Reproducible steps needed labels Oct 15, 2024
@melvin-bot melvin-bot bot changed the title [DEV] - Console Warning: Function components cannot be given refs [$250] [DEV] - Console Warning: Function components cannot be given refs Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

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

@hoangzinh
Copy link
Contributor

Thanks for all your proposals. Btw, @jayeshmangwani proposal looks good to me

Link to proposal #50676 (comment)

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 16, 2024

Triggered auto assignment to @rlinoz, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@rlinoz
Copy link
Contributor

rlinoz commented Oct 16, 2024

I think GH Actions will fail if we touch those files and don't replace the withOnyx call, so go with that in both places you mentioned

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 16, 2024
Copy link

melvin-bot bot commented Oct 16, 2024

📣 @hoangzinh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels Oct 17, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 17, 2024
@melvin-bot melvin-bot bot changed the title [$250] [DEV] - Console Warning: Function components cannot be given refs [HOLD for payment 2024-10-30] [$250] [DEV] - Console Warning: Function components cannot be given refs Oct 23, 2024
Copy link

melvin-bot bot commented Oct 23, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 23, 2024
Copy link

melvin-bot bot commented Oct 23, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.52-5 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 2024-10-30. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Oct 23, 2024

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:

  • [@hoangzinh / @jayeshmangwani] The PR that introduced the bug has been identified. Link to the PR:
  • [@hoangzinh / @jayeshmangwani] 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:
  • [@hoangzinh / @jayeshmangwani] 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:
  • [@hoangzinh / @jayeshmangwani] Determine if we should create a regression test for this bug.
  • [@hoangzinh / @jayeshmangwani] 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.
  • [@garrettmknight] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 29, 2024
@garrettmknight
Copy link
Contributor

@rojiphil did you work on this one at all or just report it?

@garrettmknight
Copy link
Contributor

Payment Summary:

  • Contributor: @jayeshmangwani $250 - submit once you've completed the checklist
  • Contributor+: @hoangzinh $250 paid via upwork

@jayeshmangwani
Copy link
Contributor

I don't think a checklist is needed here since these are console warning and should have been caught when we initially passed the ref to the functional component during creation or migration of the page.
Let me know if you think otherwise, @garrettmknight @hoangzinh

@hoangzinh
Copy link
Contributor

Agreed @jayeshmangwani.

@rojiphil
Copy link
Contributor

did you work on this one at all or just report it?

@garrettmknight I just reported it. No payment is due for me here. Thanks.

@garrettmknight
Copy link
Contributor

Thanks, I'll undo the payment and we can close.

@garrettmknight
Copy link
Contributor

@hoangzinh I accidentally requested a refund on this one in Upwork. Please decline.

@hoangzinh
Copy link
Contributor

Okay, no worry @garrettmknight

@JmillsExpensify
Copy link

I confirm that this payment summary is accurate.

@garrettmknight
Copy link
Contributor

$250 approved for @jayeshmangwani

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Development

No branches or pull requests

9 participants