-
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
useOnyx type improvements #534
useOnyx type improvements #534
Conversation
@roryabraham @blazejkustra I've also upgraded both Onyx and E/App TS to 5.4.5 to be able to use NoInfer type, necessary to fix |
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 code seems good to me
Putting this on HOLD because I'm going to be OOO next week, and will return on May 6th. |
@roryabraham @techievivek I'm taking this PR off the hold. |
🚀Published to npm in v2.0.37 |
Details
This PR does the following changes:
useOnyx
to returnundefined
instead ofnull
, thus allowing us to use default values more easily.OnyxEntry
andOnyxCollection
types to allowundefined
values (necessary because of the change above).Onyx.set
andOnyx.merge
types to disallow passingundefined
directly (like it was before).Onyx.connect
callback's value type to excludeundefined
(undefined
will never be passed).withOnyx
.useOnyx
return read-only value to avoid future situations like this one (it's not committed yet but the problem was because an Onyx value was being mutated during runtime, which causesgetSnapshot()
to always fail the deep-equality check and re-render infinitely).initialValue
type to avoid inferuseOnyx
's return valueinitialValue
.Related Issues
$ Expensify/App#34339
Automated Tests
Manual Tests
Some common tasks on E/App:
useOnyx
).useOnyx
).useOnyx
).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
I'm having issue to build Android app.
Android: mWeb Chrome
Screen.Recording.2024-04-26.at.15.37.33-compressed.mov
iOS: Native
It's failing runtime due to changes on this repo's
main
.iOS: mWeb Safari
Screen.Recording.2024-04-26.at.15.47.24-compressed.mov
MacOS: Chrome / Safari
Screen.Recording.2024-04-26.at.15.52.43-compressed.mov
Screen.Recording.2024-04-26.at.15.54.12-compressed.mov
MacOS: Desktop
Screen.Recording.2024-04-26.at.15.56.19-compressed.mov