Skip to content

[Due for payment 2025-04-02] [$250] [Dev] Console Error: A props object containing a "key" prop is being spread into JSX #58261

Closed

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: v9.1.10-3 Develop
Reproducible in staging?: Needs Reproduction
Reproducible in production?: Needs Reproduction
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
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: @QichenZhu
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Log in to the development HybridApp on Android or iOS.
  2. Go to the Reports page.

Expected Result:

No console errors on the Reports page.

Actual Result:

Console Error: A props object containing a "key" prop is being spread into JSX.

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021899899286639282267
  • Upwork Job ID: 1899899286639282267
  • Last Price Increase: 2025-03-12
Issue OwnerCurrent Issue Owner: @dominictb

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    retest-weeklyApply this label if you want this issue tested on a Weekly basis by Applause
    on Mar 12, 2025
  2. melvin-bot commented on Mar 12, 2025

    @melvin-bot

    Triggered auto assignment to @isabelastisser (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 Mar 12, 2025

    @MelvinBot
    Contributor

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

  4. dominictb commented on Mar 12, 2025

    @dominictb
    Contributor

    @isabelastisser I can reproduce this with the following steps:

    Precondition: Have saved search items. If you don't, create some.

    1. Open Reports tab
    2. The console error shows up

    Image

    Please assign this to me as per this Slack thread.

  5. github-actions commented on Mar 12, 2025

    @github-actions
    Contributor

    ⚠️ @Shahidullah-Muffakir Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  6. Shahidullah-Muffakir commented on Mar 12, 2025

    @Shahidullah-Muffakir
    Contributor

    Proposal

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

    We're seeing console errors on the Reports page stating "A props object containing a 'key' prop is being spread into JSX.

    What is the root cause of that problem?

    The SavedSearchMenuItem type includes a key property. When these menu items are mapped in the PopoverMenu component, all properties including key are spread into the JSX using {...menuItemProps}. React treats key as a special prop that shouldn't be passed to components, which causes the console error.

    {...menuItemProps}

    type SavedSearchMenuItem = MenuItemWithLink & {
    key: string;
    hash: string;
    query: string;
    styles?: Array<ViewStyle | TextStyle>;
    };

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

    We should keep the key property for identification purposes but prevent it from being passed as a prop to React components. There are 4 options:

    1. In SearchTypeMenuPopover.tsx, rename the key property in SavedSearchMenuItem to something like itemKey or searchKey and update all references to use this new name.
    type SavedSearchMenuItem = MenuItemWithLink & {
        itemKey: string; // Changed from 'key' to 'itemKey'
        hash: string;
        query: string;
        styles?: Array<ViewStyle | TextStyle>;
    };
    1. Alternatively, we can distructure the Key separately here, so it won't be passed in the props spreading:
      Update this:
      const renderedMenuItems = currentMenuItems.map((item, menuIndex) => {

      as:
    const renderedMenuItems = currentMenuItems.map(({ key, ...item }, menuIndex)
    1. Alternatively, we can remove the 'key' prop dynamically, as the key prop is already passed, update this:
      {...menuItemProps}

    to this:

                    {...Object.fromEntries(Object.entries(menuItemProps).filter(([key]) => key !== 'key'))} 
    1. Alternatively, in PopoverMenu.tsx, we could extract and use the key for React's list rendering but exclude it from props spreading:
    const renderedMenuItems = currentMenuItems.map((item, menuIndex) => {
        const {text, onSelected, subMenuItems, shouldCallAfterModalHide, key, ...menuItemProps} = item;
        return (
            <OfflineWithFeedback
                 key={key || `${item.text}_${menuIndex}`}
                pendingAction={item.pendingAction}
            >
                <FocusableMenuItem
                      key={key || `${item.text}_${menuIndex}`}
                    pressableTestID={`PopoverMenuItem-${item.text}`}
                    title={text}
                    onPress={() => selectItem(menuIndex)}
                    // other props...
                    {...menuItemProps}
                />
            </OfflineWithFeedback>
        );
    });

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can write test to ensure the menuItemProps does not have key prop in it, while passing it here:

    {...menuItemProps}

    What alternative solutions did you explore? (Optional)

  7. daledah commented on Mar 12, 2025

    @daledah
    Contributor

    Proposal

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

    Console Error: A props object containing a "key" prop is being spread into JSX.

    What is the root cause of that problem?

    SavedSearchMenuItem has a key prop:

    When adding saved search to menu items all props are passed

    So when rendering Popover menu the key props is also passed

    {...menuItemProps}

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

    I don't see any use of key for SavedSearchMenuItem, so we can simply remove this prop.

    Additionally, there are two similar SavedSearchMenuItem defined:

    type SavedSearchMenuItem = MenuItemWithLink & {
    key: string;
    hash: string;
    query: string;
    styles?: Array<ViewStyle | TextStyle>;
    };

    type SavedSearchMenuItem = MenuItemWithLink & {
    key: string;
    hash: string;
    query: string;
    styles?: Array<ViewStyle | TextStyle>;
    };

    So we should DRY code and use type from SearchUIUtils.ts only.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    This is a typecast error so I think no test is required

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    and removed on Mar 12, 2025
  9. melvin-bot commented on Mar 12, 2025

    @melvin-bot
  10. 33 remaining items

  11. melvin-bot commented on Mar 26, 2025

    @melvin-bot

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

  12. melvin-bot commented on Mar 26, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.18-4 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 2025-04-02. 🎊

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

  13. melvin-bot commented on Mar 26, 2025

    @melvin-bot

    @dominictb @isabelastisser @dominictb The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. dominictb commented on Mar 27, 2025

    @dominictb
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] 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: Add search input to mobile search page(with fixed performance) #56326 (comment)

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

      No regression test is needed because this is a dev-only issue.

  15. melvin-bot commented on Apr 2, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@isabelastisser)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1899899286639282267/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. isabelastisser commented on Apr 2, 2025

    @isabelastisser
    Contributor
  17. isabelastisser commented on Apr 2, 2025

    @isabelastisser
    Contributor

    @dominictb what's your Upwork profile?

  18. dominictb commented on Apr 3, 2025

    @dominictb
    Contributor

    @isabelastisser My Upwork profile is https://www.upwork.com/freelancers/~01f70bed1934fd35d5. Could you please send an offer? TIA!

  19. melvin-bot commented on Apr 7, 2025

    @melvin-bot

    @dominictb Whoops! This issue is 2 days overdue. Let's get this updated quick!

  20. isabelastisser commented on Apr 7, 2025

    @isabelastisser
    Contributor

    @dominictb, I messaged you in Upwork.

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.DailyKSv2Hot PickReady for an engineer to pick up and run withInternalRequires API changes or must be handled by Expensify staffretest-weeklyApply this label if you want this issue tested on a Weekly basis by Applause

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions