-
Notifications
You must be signed in to change notification settings - Fork 74
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 an incorrect method of looking up previous keys #407
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-native.mp4Android: mWeb Chromeandroid-chrome-2023-10-30_15.07.23.mp4iOS: Nativeios-native-2023-10-30_16.21.41.mp4iOS: mWeb Safariios-safari-2023-10-30_16.24.08.mp4MacOS: Chrome / Safarichrome-desktop-2023-10-30_15.00.23.mp4MacOS: Desktopmac-desktop-2023-10-30_16.26.27.mp4 |
Note: I'm testing against |
@mountiny Will do! |
Ah yes with #408 that now works fine against v1.0.109!
chrome-desktop-2023-10-30_12.23.39.mp4 |
Hm, the failing test is leading me to believe I didn't have the right solution. I'm still digging into this. |
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.
Tests well!
Haha unfortunate timing! 😅 |
OK, after testing this for a while, I checked out the branch from #408 and to my surprise, the original problem could not be reproduced with the infinite avatars. I think my solution here was kind of maybe working around the root of the problem. I think this can be closed. |
This was reported while testing Expensify/App#29169 (comment)
Details
I was able to reproduce the issue with the infinite loading of avatars. While debugging the problem, I found that it was
ReportScreen.js
which was infinitely re-rendering. This manifested in the infinite loading of avatars. SinceReportScreen
is at the top of the view hierarchy, I concluded the issue was definitely inwithOnyx()
.To debug it further, I began to inspect what happened when
componentDidUpdate
runs, and then checks to see if the key changed (eg.previousKey !== newKey
). I found that the logic was properly detecting that the key changed, sowithOnyx
correctly tried to reconnect with the new key. When the new connection happened, the logic is supposed to remember what the previous key was (eg.mapOnyxToState[statePropertyName].previousKey = key;
). This triggerscomponentDidUpdate()
again and I found that thepreviousKey
was always wrong. It wasn't actually changing, sowithOnyx
went into an infinite loop trying to reconnect to the same keys over and over again.I fixed it by utilizing
prevProps
andprevState
arguments fromcomponentDidUpdate()
to more accurately calculate what the previous and current keys were, rather than relying on a reference tomapOnyxToState[statePropertyName].previousKey
. This now correctly picked up the change to keys and prevents the infinite connection.Related Issues
Expensify/App#29169
Automated Tests
None
Manual Tests
This requires a little bit of setup.
Setup in NewDot
main
with version1.0.100
of Onyx), log in as a user and be sure you have an avatar uploadedSetup NewDot to run the Onyx fix
react-native-onyx
directory and runnpm run build && cp -r dist ~/Expensidev/App/node_modules/react-native-onyx
to copy the changes from this PR into NewDot (you may need to adjust the file paths)npm run web
Author Checklist
### Related Issues
section aboveTests
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Mobile Web - Chrome
cannot test because no access to network console
Mobile Web - Safari
cannot test because no access to network console
Desktop
iOS
cannot test because no access to network console
Android
cannot test because no access to network console