-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Lodash: Refactor away from _.delay()
#42966
Conversation
Size Change: 0 B Total Size: 1.27 MB ℹ️ View Unchanged
|
Hey there 👋 I will check this PR, I'll unassign a few people from the reviewers list. |
Thanks a bunch, @geriux 🙌 I've fixed a couple of failing tests in the meantime. TIL about our |
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.
LGTM! I've tested both on iOS and Android. Thanks for adding clearTimeouts
we should've had these before 😅
Thanks a ton for the thorough testing @geriux 🙌 |
What?
This PR removes the
_.delay()
usage completely and deprecates the function. Prior usage is only in RN components.Why?
Lodash is known to unnecessarily inflate the bundle size of packages, and in most cases, it can be replaced with native language functionality. See these for more information and rationale:
@wordpress/api-fetch
package haslodash
as a dependency #39495How?
_.delay()
is essentiallysetTimeout()
with a few additional checks - ensuring that the callback is actually callable, and that the timeout duration is actually a number. None of these are necessary for our use cases, so replacing withsetTimeout()
is just fine.This also unveiled an issue with the previous implementation that used
delay()
- we weren't cleaning the timeouts up when components unmount, and that's bad for a couple of reasons:So in this PR we're also using the opportunity to fix that and clean up all the timeouts on unmount.
Testing Instructions
Inserter
: Follow testing instructions from [RNMobile] Improve block inserter accessibility #25549 and verify they still work.MediaUpload
: Follow testing instructions from [RNMobile] Simplify media insertion flow Part 2 - media upload #29547 and verify they still work.ColumnsEdit
: Follow testing instructions from [RNMobile] Support percentage in columns #23828 and verify they still work.LinkPickerScreen
: Follow testing instructions from [RNMobile] Upgrade to RN 0.66 #36328 (the Link Picker section) and verify they still work.npm run native test -- --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache"