More minor fixes for the Onyx bump in E/App#561
Conversation
| 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.
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.
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.
Thanks for the explanation!
| 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.
Same: Why did you move the operation to here? Shouldn't we have tests for both cases?
mountiny
left a comment
There was a problem hiding this comment.
Just a NAB though seems like we are good to go
mountiny
left a comment
There was a problem hiding this comment.
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:
useOnyxwill never resolve loading state if the value from cache isundefined(because ofdeepEqualingetSnapshot)initialValuebeing set, before we can call these methods.Related Issues
Expensify/App#42772
Automated Tests
Manual Tests
Author Checklist
### Related Issuessection aboveTestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Avataris modified, I verified thatAvataris working as expected in all cases)mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop