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

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

Closed
2 of 8 tasks
m-natarajan opened this issue Mar 12, 2025 · 30 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 Hot Pick Ready for an engineer to pick up and run with Internal Requires API changes or must be handled by Expensify staff retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause

Comments

@m-natarajan
Copy link

m-natarajan commented Mar 12, 2025

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: 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
@m-natarajan m-natarajan added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Needs Reproduction Reproducible steps needed retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause labels Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

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.

@MelvinBot
Copy link

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

@dominictb
Copy link
Contributor

dominictb commented Mar 12, 2025

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

Copy link
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).

@Shahidullah-Muffakir
Copy link
Contributor

Shahidullah-Muffakir commented Mar 12, 2025

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)

@daledah
Copy link
Contributor

daledah commented Mar 12, 2025

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.

@isabelastisser isabelastisser added External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors and removed Needs Reproduction Reproducible steps needed labels Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

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

@melvin-bot melvin-bot bot changed the title [Dev] Console Error: A props object containing a "key" prop is being spread into JSX [$250] [Dev] Console Error: A props object containing a "key" prop is being spread into JSX Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

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

@isabelastisser isabelastisser added Internal Requires API changes or must be handled by Expensify staff Hot Pick Ready for an engineer to pick up and run with and removed External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors labels Mar 12, 2025
@dominictb
Copy link
Contributor

@isabelastisser You might have missed to assign me 😄

@dominictb
Copy link
Contributor

@daledah @Shahidullah-Muffakir Can you confirm if we can safely remove the key (or rename key to itemKey) from SavedSearchMenuItem? Let's find out why it was added at the beginning and where it is used currently.

@daledah
Copy link
Contributor

daledah commented Mar 14, 2025

@dominictb

SavedSearchMenuItems is used in two places:

  • In SearchTypeMenuPopover, where we have the bug in this issue
  • In SearchTypeMenu, where an array of SavedSearchMenuItems is passed to MenuItemList:

menuItems={menuItems}

Then in MenuItemList, key prop is used in two places:

key={key ?? menuItemProps.title}

key={key ?? menuItemProps.title}

But both places already have fallback value to be title.

I also ran all tests with the key prop removed and passed all of them. So I believe key prop is not in use here.

The prop was added in #56326. I don't see any place mentioned this, so I asked the author here

@melvin-bot melvin-bot bot added the Overdue label Mar 16, 2025
@ntdiary
Copy link
Contributor

ntdiary commented Mar 17, 2025

@isabelastisser, can you please help unassign me? seems I can't unassign myself. :D

@melvin-bot melvin-bot bot removed the Overdue label Mar 17, 2025
Copy link

melvin-bot bot commented Mar 20, 2025

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

@mollfpr
Copy link
Contributor

mollfpr commented Mar 20, 2025

@Shahidullah-Muffakir proposal looks good to me! Assigning!

@Shahidullah-Muffakir
Copy link
Contributor

PR is ready for review.
cc. @dominictb

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Mar 26, 2025
@melvin-bot melvin-bot bot changed the title [$250] [Dev] Console Error: A props object containing a "key" prop is being spread into JSX [Due for payment 2025-04-02] [$250] [Dev] Console Error: A props object containing a "key" prop is being spread into JSX Mar 26, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 26, 2025
Copy link

melvin-bot bot commented Mar 26, 2025

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

Copy link

melvin-bot bot commented Mar 26, 2025

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:

Copy link

melvin-bot bot commented Mar 26, 2025

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

@dominictb
Copy link
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.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 1, 2025
Copy link

melvin-bot bot commented Apr 2, 2025

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

@isabelastisser
Copy link
Contributor

isabelastisser commented Apr 2, 2025

Payment summary:

Contributor @Shahidullah-Muffakir paid $250 via Upwork https://www.upwork.com/nx/wm/offer/106762783
C+ @dominictb $250 pending in Upwork. https://www.upwork.com/jobs/~021899899286639282267

@isabelastisser
Copy link
Contributor

@dominictb what's your Upwork profile?

@dominictb
Copy link
Contributor

dominictb commented Apr 3, 2025

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

Copy link

melvin-bot bot commented Apr 7, 2025

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

@melvin-bot melvin-bot bot added the Overdue label Apr 7, 2025
@isabelastisser
Copy link
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
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Hot Pick Ready for an engineer to pick up and run with Internal Requires API changes or must be handled by Expensify staff retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause
Projects
None yet
Development

No branches or pull requests

9 participants