-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: Remove withCurrentReportID HOC #54702
fix: Remove withCurrentReportID HOC #54702
Conversation
@dominictb Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-01-02.at.22.51.57.movAndroid: mWeb ChromeScreen.Recording.2025-01-02.at.22.44.35.moviOS: NativeScreen.Recording.2025-01-02.at.22.50.29.moviOS: mWeb SafariScreen.Recording.2025-01-02.at.22.46.35.movMacOS: Chrome / SafariScreen.Recording.2025-01-02.at.22.42.16.movMacOS: DesktopScreen.Recording.2025-01-02.at.22.54.19.mov |
import type {ComponentType, ForwardedRef, RefAttributes} from 'react'; | ||
import React, {createContext, forwardRef, useCallback, useMemo, useState} from 'react'; | ||
import getComponentDisplayName from '@libs/getComponentDisplayName'; | ||
import React, {createContext, useCallback, useMemo, useState} from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the idea to just get rid of this whole file? I only see one place using updateCurrentReportID
, which could also be removed if I'm not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luacmartins I don't think we can remove updateCurrentReportID
. We are using updateCurrentReportID
to update the currentReportID
when there is a navigation state change.
That helps sync the LHN item focused on LHN, and the currently opened report. If we don't do that, when select an item from LHN, the corresponding report will be opened but the LHN item won't be focused. The issue video is can be found at the bottom.
- We call updateCurrentReportID with the new navigation state
App/src/libs/Navigation/NavigationRoot.tsx
Lines 172 to 173 in 04cd7b0
setTimeout(() => { | |
currentReportIDValue?.updateCurrentReportID(state); |
- Then we get the new navigation’s reportID here and updated currentReportID with the new navigation state reportID
App/src/components/withCurrentReportID.tsx
Lines 28 to 30 in 575a66d
const updateCurrentReportID = useCallback( | |
(state: NavigationState) => { | |
const reportID = Navigation.getTopmostReportId(state); |
- Then LHN item will be updated with the new currentReportID, and the right item will be focused.
const isReportFocused = isFocused && currentReportIDValue?.currentReportID === reportID;
But, I believe we can move CurrentReportIDContextProvider
from withCurrentReportID.tsx
to useCurrentReportID.tsx
and delete withCurrentReportID.tsx
file. Should I do that?
POC
Screen.Recording.2025-01-03.at.1.49.03.in.the.afternoon.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we'd want to move from the HOC to the hook fully. Let's migrate that code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I will do that.
@etCoderDysto What is the ETA for this? |
Sorry for the delay. I will make the changes my by tomorrow. |
Thanks! Looking forward to the update |
…ince it is not used anywhere else
…it is not used anywhere else
@dominictb @luacmartins PR is ready for further review. I have migrated all the code form |
looks good |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.83-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.83-5 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.83-5 🚀
|
Explanation of Change
In this PR we replace withCurrentReportID HOC with useCurrentReportID hook, and remove the withCurrentReportID HOC from withCurrentReportID.tsx
Fixed Issues
$ #50510
PROPOSAL: #50510 (comment)
Tests
Same as QA steps
Offline tests
Same as QA steps
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android.chrome.mp4
iOS: Native
iOS.mp4
iOS: mWeb Safari
ios.safari.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
Desktop.mp4