-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Refactor: Remove Avatar platform specific code #15663
Refactor: Remove Avatar platform specific code #15663
Conversation
a267ce4
to
ec58ab9
Compare
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.
Added some notes to aid the reviewer
package.json
Outdated
"@expensify/react-native-web": "0.18.12", | ||
"@expensify/react-native-web": "github:kidroca/react-native-web#8188a8b23d838dbe9fee9c856d3923bed6c0baf4", |
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.
This is the complied code containing the flicker fix
After it's merged the package should be updated to point to the new version
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.
should we throw a hold on this PR until Expensify/react-native-web#15 is merged?
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.
should we throw a hold on this PR until Expensify/react-native-web#15 is merged?
Yes, added HOLD to the title
@@ -119,12 +118,7 @@ class Avatar extends PureComponent { | |||
</View> | |||
) | |||
: ( | |||
<Image | |||
source={{uri: this.props.source}} | |||
defaultSource={getAvatarDefaultSource(this.props.source)} |
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.
The defaultSource
workaround is no longer needed.
We just pass source
this.state = { | ||
imageSource: undefined, | ||
}; |
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.
Having imageSource
with undefined
value initially would render no image for the first render
We don't have to use state for imageSource
- it doesn't save us from re-renders, because most usages pass source like <Image soruce={{ uri: '...' }} />
(a new object created inline)
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.
The debounce
here was removed because it no longer has any effect (and was a workaround) as discussed here: #9279 (comment)
(Also it's inconsistent with the .native
component where no debounce is used)
There are further changes that we can add to the Image component and I can open a follow up PR:
- remove
configureOnLoad
- this was a workaround needed because at the timereact-native-web
did not provide dimension in the originalonLoad
callback - Turn
Image
into a functional component - no lifecycle and state are used.
I do both of this changes here:
but the PR is on hold
Reviewer Checklist
Screenshots/VideosWeb15663.Web.mov15663.Web.2.mp4Mobile Web - Chrome15663.mWeb-Chrome.mp4Mobile Web - Safari15663.mWeb.Safari.mp415663.mWeb-Safari.2.mp4Desktop15663.Desktop.mp4iOS15663.iOS.2.mp4Android15663.Android.mp415663.iOS.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.
Great work on this @kidroca! Looks good to me and tests well 👍
Thanks @mollfpr BTW no one is assigned to review it Current PR servers to verify the fix is working in App, but it has to wait for the actual fix to be released in |
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, I'll approve once we've gotten the react-native-web PR merged and the package.json updated with the correct version number.
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.
I am going to try to release the new version of our fork, @kidroca can you resolve the merge conflicts in the meantime, thanks!
I don't see the new |
e335e60
to
33560af
Compare
@kidroca should be released in version |
33560af
to
d3a0794
Compare
d3a0794
to
c4abb46
Compare
Updated to latest @bondydaa you approved this PR before but there's a change that I had to make: https://github.com/Expensify/App/pull/15663/files#r1144494327 ✅ Ready for Review |
Screenshots/VideosWeb15663.Web.mp4Mobile Web - Chrome15663.mWeb-Chrome.mp4Mobile Web - Safari15663.mWeb-Safari.mp4Desktop15663.Desktop.mp4iOS15663.iOS.mp4Android15663.Android.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.
Test well 👍
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.
✋ 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/mountiny in version: 1.2.89-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.2.89-0 🚀
|
Details
The avatar component uses a workaround to prevent a flicker bug in react-native-web
We submitted a fix for react-native-web and the workaround is no longer needed
Why was the Image component updated
The code contributed to the flicker because the
imageSource
starts withundefined
and is only updated after mount - this causes the first render pass to show no image (this happens very quickly, but sometimes a flicker can be seen)Fixed Issues
$ #14278
PROPOSAL: #9183 (comment)
FORK PR: Expensify/react-native-web#15
Tests
There should be no flicker
Image
onLoad
was slightly changed, it should not cause a regressionOffline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)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
Screen.Recording.2023-03-04.at.19.48.03.mov
Mobile Web - Chrome
Android.Emulator.-.Pixel_2_API_29_5554.2023-03-06.15-35-04.mp4
Mobile Web - Safari
Desktop
Screen.Recording.2023-03-04.at.20.40.49.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.-.2023-03-04.at.20.47.43.mp4
Android
Android.Emulator.-.Pixel_2_API_29_5554.2023-03-06.15-30-22.mp4