-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Migrate FloatingMessageCounter to function component #22912
Conversation
@rushatgabhane 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] |
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.
Looks good, just some questions
} | ||
function FloatingMessageCounter(props) { | ||
const {translate} = useLocalize(); | ||
const translateY = useMemo(() => new Animated.Value(MARKER_INACTIVE_TRANSLATE_Y), []); |
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.
Note to self: This will calculate the value only once i.e. on mount.
toValue: MARKER_ACTIVE_TRANSLATE_Y, | ||
duration: 80, | ||
useNativeDriver: true, | ||
}).start(); | ||
} | ||
}, [translateY]); |
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.
translateY
will never change, right? Why is it in the dependency array?
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.
When running npm run lint
it gives me a warning that useCallback
is missing a dependency translateY
. It suggests adding it or removing the dependency array. When I remove the dependency array and run lint
again it tells me to add an array. I kept translateY
as a dependency to keep lint
happy 😅.
Would it be best to use something else other than useCallback
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.
no, this is fine the.
} else { | ||
hide(); | ||
} | ||
}, [props.isActive, show, hide]); |
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.
looks good
|
||
export default withLocalize(FloatingMessageCounter); | ||
FloatingMessageCounter.displayName = 'FloatingMessageCounter'; | ||
export default React.memo(FloatingMessageCounter); |
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.
Why are we memoizing the component? Did you notice any performance issues?
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.
FloatingMessageCounter
used to be PureComopent
. Which, I believe that it prevents the components from re-rendering unless their own states or props are changed.
I used React.memo
to have the same effect.
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.
thanks, i missed that
Reviewer Checklist
Screenshots/Videos |
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.
LGTM
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.
LGTM!
✋ 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/johnmlee101 in version: 1.3.49-0 🚀
|
🚀 Deployed to staging by https://github.com/johnmlee101 in version: 1.3.50-0 🚀
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.49-3 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.50-3 🚀
|
Details
Migrate FloatingMessageCounter to function component
Fixed Issues
$ #16261
PROPOSAL: #16261 (comment)
Tests
make sure there are plenty of past messages that gives you the ability to scroll up at least 5 messages
a
andb
open that are in the same groupa
looking at a different group and theb
in the room they shareb
send a messagea
return to the group chat withb
(fora
there will be a new message)a
scroll up to the past messages( there should be a green button that comes down with the text New messages)Offline tests
Works only when online
QA Steps
make sure there are plenty of past messages that gives you the ability to scroll up at least 5 messages
a
andb
open that are in the same groupa
looking at a different group and theb
in the room they shareb
send a messagea
return to the group chat withb
(fora
there will be a new message)a
scroll up to the past messages( there should be a green button that comes down with the text New messages)PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
New.Expensify.-.Google.Chrome.mp4
Mobile Web - Chrome
New.Expensify.-.Google.Chrome.web.phone.mp4
Mobile Web - Safari
Desktop
iOS
Android