Page MenuHomePhabricator

[native] Convert `ConnectedMessage` class component to functional `Message`
ClosedPublic

Authored by atul on Aug 31 2023, 8:46 AM.
Tags
None
Referenced Files
F3348888: D9051.diff
Fri, Nov 22, 4:24 PM
Unknown Object (File)
Sat, Nov 9, 8:15 PM
Unknown Object (File)
Wed, Nov 6, 4:24 AM
Unknown Object (File)
Sun, Nov 3, 7:44 PM
Unknown Object (File)
Sun, Nov 3, 7:44 PM
Unknown Object (File)
Sun, Nov 3, 7:44 PM
Unknown Object (File)
Sun, Nov 3, 7:41 PM
Unknown Object (File)
Sun, Nov 3, 7:23 PM
Subscribers

Details

Summary

Based on profiling of "navigating to thread w/ varun" scenario, the re-renders of Message take ~100ms. There's a few nested class components here, so converting to functional to try to memoize things in a more specific way to avoid re-renders.


Depends on D9050

Test Plan

Message component continues to appear as expected and we're skipping render of a few child components (not in a super impactful way, however)

Diff Detail

Repository
rCOMM Comm
Branch
arcpatch-D9051 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Aug 31 2023, 8:47 AM
tomek requested changes to this revision.Sep 1 2023, 3:24 AM
tomek added inline comments.
native/chat/message.react.js
52–55 ↗(On Diff #30660)

It isn't equivalent to the original code where we were checking the prev props - is there a reason for this change?

58–60 ↗(On Diff #30660)

This can be optimized further by checking only the prop that is necessary (we're using only keyboardState?.dismissKeyboard). (Might be necessary to assign keyboardState?.dismissKeyboard to a separate variable.)

138–149 ↗(On Diff #30660)

It is probably easier to use React.memo instead of memoizing the return value by hand

This revision now requires changes to proceed.Sep 1 2023, 3:24 AM
atul requested review of this revision.Sep 1 2023, 1:06 PM
atul added inline comments.
native/chat/message.react.js
52–55 ↗(On Diff #30660)

It isn't equivalent to the original code where we were checking the prev props - is there a reason for this change?

I think it's equivalent because we have focusedOrStartsConversation in the dep list so LayoutAnimation.easeInEaseOut(); should fire in the same conditions?

58–60 ↗(On Diff #30660)

Good point! Will update with that change

138–149 ↗(On Diff #30660)

Yeah I didn't want to wrap the whole thing in React.memo because of indentation, but I guess I could export a React.memo(Message) from this file

tomek added inline comments.
native/chat/message.react.js
52–55 ↗(On Diff #30660)

Ah, that makes sense! You're right.

This revision is now accepted and ready to land.Sep 4 2023, 5:05 AM

address tomek's feedback

This revision was landed with ongoing or failed builds.Sep 5 2023, 10:52 AM
This revision was automatically updated to reflect the committed changes.