-
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 _.orderBy()
#45146
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +98 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
That is correct, the full support for |
c442265
to
663474a
Compare
// Stable sort: maintaining original array order | ||
if ( orderA > orderB ) { | ||
return 1; | ||
} else if ( orderB > orderA ) { | ||
return -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.
Now that RN has been upgraded to 0.69.4 this is ready for review! |
9bebdb4
to
f63990c
Compare
Thanks for taking a look @sgomes! Feedback has been addressed and this is ready for another look. |
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, with one final comment.
Also, it would be good to get some validation that this works correctly with React Native, given that this is what last held up the commit.
Hey there 👋 I was AFK but I'll check it out today. |
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 is working well on mobile. I tested on both Android and iOS 🚀
Thank you, folks 🙌 |
What?
This PR removes Lodash's
_.orderBy()
completely and deprecates the method. We're introducing a custom sorting function to preserve the same behavior as the Lodash function. There are just a few usages and conversion is pretty straightforward.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?
We're introducing a simple custom sorting function and using it to replace the complex Lodash implementation.
Testing Instructions
/
in the editor is sorted the same way.trunk
.trunk
.