Skip to content

[HOLD for payment 2024-10-30] [$250] [DEV] - Console Warning: Function components cannot be given refs #50676

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com 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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 11, 2024
  2. melvin-bot commented on Oct 11, 2024

    @melvin-bot

    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.

  3. MelvinBot commented on Oct 11, 2024

    @MelvinBot
    Contributor

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

  4. jayeshmangwani commented on Oct 11, 2024

    @jayeshmangwani
    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({
  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    and removed on Oct 15, 2024
  6. changed the title [-][DEV] - Console Warning: Function components cannot be given refs[/-] [+][$250] [DEV] - Console Warning: Function components cannot be given refs[/+] on Oct 15, 2024
  7. melvin-bot commented on Oct 15, 2024

    @melvin-bot
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 15, 2024
  9. 20 remaining items

  10. melvin-bot commented on Oct 23, 2024

    @melvin-bot

    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:
  11. garrettmknight commented on Oct 30, 2024

    @garrettmknight
    Contributor

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

  12. garrettmknight commented on Oct 30, 2024

    @garrettmknight
    Contributor

    Payment Summary:

    • Contributor: @jayeshmangwani $250 - submit once you've completed the checklist
    • Contributor+: @hoangzinh $250 paid via upwork
  13. jayeshmangwani commented on Oct 30, 2024

    @jayeshmangwani
    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

  14. hoangzinh commented on Oct 30, 2024

    @hoangzinh
    Contributor
  15. rojiphil commented on Oct 31, 2024

    @rojiphil
    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.

  16. garrettmknight commented on Oct 31, 2024

    @garrettmknight
    Contributor

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

  17. garrettmknight commented on Oct 31, 2024

    @garrettmknight
    Contributor

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

  18. hoangzinh commented on Oct 31, 2024

    @hoangzinh
    Contributor

    Okay, no worry @garrettmknight

  19. JmillsExpensify commented on Nov 6, 2024

    @JmillsExpensify
    Contributor

    I confirm that this payment summary is accurate.

  20. garrettmknight commented on Nov 6, 2024

    @garrettmknight
    Contributor

    $250 approved for @jayeshmangwani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions