-
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: Remove _.isEmpty()
from Fill
props
#51096
Conversation
Size Change: +23 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
@@ -38,7 +33,10 @@ export default function BlockControlsFill( { | |||
// Children passed to BlockControlsFill will not have access to any | |||
// React Context whose Provider is part of the BlockControlsSlot tree. | |||
// So we re-create the Provider in this subtree. | |||
const value = ! isEmpty( fillProps ) ? fillProps : null; | |||
const value = | |||
fillProps && Object.keys( fillProps ).length > 0 |
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.
fillProps
should be an object since it's coming from component props:
const FillComponent = ( props ) => <Fill name={ key } { ...props } />; |
@@ -82,7 +77,8 @@ function ToolsPanelInspectorControl( { children, resetAllFilter, fillProps } ) { | |||
// access to any React Context whose Provider is part of | |||
// the InspectorControlsSlot tree. So we re-create the | |||
// Provider in this subtree. | |||
const value = ! isEmpty( fillProps ) ? fillProps : null; | |||
const value = | |||
fillProps && Object.keys( fillProps ).length > 0 ? fillProps : null; |
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.
fillProps
should be an object since it's coming from component props:
const FillComponent = ( props ) => <Fill name={ key } { ...props } />; |
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 changes look good in my tests. Thank you, Marin!
What?
This PR removes Lodash's
_.isEmpty()
from the usages that checkFill
props.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 checking if the props are truthy, and if they are, we verify that it's not an empty object by using
Object.keys().length
.Testing Instructions