Refactor ParticipantLocalTime to function component#20300
Conversation
|
@fedirjh @roryabraham One of you needs to 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] |
fedirjh
left a comment
There was a problem hiding this comment.
Looks good. left minor comment about props destruction.
| } | ||
|
|
||
| function ParticipantLocalTime(props) { | ||
| const {participant, preferredLocale, translate} = props; |
There was a problem hiding this comment.
I think we should avoid props destruction as per Style guidelines
There was a problem hiding this comment.
Seems we have a similar cases that got resolved with a partial destruction , you can check this thread https://expensify.slack.com/archives/C01GTK53T8Q/p1684969645381109
There was a problem hiding this comment.
Are you suggesting I shouldn't destructure translate because that is not watched and we can keep accessing it as props.translate?
If that is the case, I don't have strong feeling toward that, but I think the best would be to have access to the translate function through a hook like it was suggested here: https://expensify.slack.com/archives/C01GTK53T8Q/p1685068222924839?thread_ts=1684969645.381109&cid=C01GTK53T8Q
There was a problem hiding this comment.
Are you suggesting I shouldn't destructure translate because that is not watched and we can keep accessing it as props.translate?
Sorry missed this comment. Well, props.translate should be watched as well, as the language may change during re-renders.
I suggested to proceed with the current destruction of props as you did.
|
|
||
| render() { | ||
| const reportRecipientDisplayName = lodashGet(this.props, 'participant.firstName') || lodashGet(this.props, 'participant.displayName'); | ||
| const reportRecipientDisplayName = lodashGet(props, 'participant.firstName') || lodashGet(props, 'participant.displayName'); |
There was a problem hiding this comment.
@aldo-expensify Shouldn’t we wrap it with useMemo ? the state update will re-render the component every second.
There was a problem hiding this comment.
Not worth it in my opinion.
useMemo doesn't prevent re-rendering.
Caching lodashGet(props, 'participant.firstName') || lodashGet(props, 'participant.displayName'); is probably more costly than recalculating it.
There was a problem hiding this comment.
is probably more costly than recalculating it.
hmmm , make sense 👍🏼
There was a problem hiding this comment.
the state update will re-render the component every second.
I just understood what you meant here. The interval is updating the state every second. I'll check if setting the state to the same value triggers a re-render or not. If it does, we should only set the state if it is really different.
There was a problem hiding this comment.
Thank you , that’s perfect.
Reviewer Checklist
Screenshots/VideosWebWeb.movMobile Web - ChromeChrome.movMobile Web - SafariSafari.movDesktopDesktop.moviOSIOS.movAndroidAndroid.mov |
|
✋ 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/roryabraham in version: 1.3.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.3.26-4 🚀
|


Details
Fixed Issues
$ #16262
PROPOSAL: GH_LINK_ISSUE(COMMENT)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Added a couple of console logs to make it more visible when the interval's callback is called and when we cancel it
Screen.Recording.2023-06-06.at.1.05.00.PM.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android