-
Notifications
You must be signed in to change notification settings - Fork 73
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
More minor fixes for the Onyx bump in E/App #561
More minor fixes for the Onyx bump in E/App #561
Conversation
@@ -257,6 +255,8 @@ describe('useOnyx', () => { | |||
expect(result.current[0]).toEqual('initial value'); | |||
expect(result.current[1].status).toEqual('loaded'); | |||
|
|||
Onyx.set(ONYXKEYS.TEST_KEY, 'test_id_1'); |
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.
Just curious: Why did you move the operation to here? Shouldn't we have tests for both cases?
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 moment we use Onyx.set
or Onyx.merge
(or any setter function) it will store the value in cache synchronously and update the storageKeys
Set in OnyxCache
. The storage will be updates asynchronously,
If we set the key before asserting for the initialValue
, we will always get undefined
, because there IS a value in cache already, even though the storage promise hasn't resolved yet.
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 for the explanation!
@@ -335,6 +329,12 @@ describe('useOnyx', () => { | |||
expect(result.current[0]).toEqual('initial value'); | |||
expect(result.current[1].status).toEqual('loaded'); | |||
|
|||
Onyx.set(ONYXKEYS.TEST_KEY, 'test1'); |
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.
Same: Why did you move the operation to here? Shouldn't we have tests for both cases?
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.
Same as above
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.
Just a NAB though seems like we are good to go
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.
Merging this to get it incorporated to the onyx bump PR per discussion here https://expensify.slack.com/archives/C05R2V5GM1S/p1718119019498549?thread_ts=1717193187.147939&cid=C05R2V5GM1S
🚀Published to npm in v2.0.48 |
@mountiny @s77rt @ikevin127
Details
This PR is adding more fixes to Onyx which are needed to resolve issues in the Onyx bump PR in E/App.
Fixes:
useOnyx
will never resolve loading state if the value from cache isundefined
(because ofdeepEqual
ingetSnapshot
)initialValue
being set, before we can call these methods.Related Issues
Expensify/App#42772
Automated Tests
Manual Tests
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
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop