-
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
Refactor Buttons block native edit component to use hooks. #25636
Conversation
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
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.
Change looks good and works well.
I had a few suggestions for changes that would improve the code slightly, would appreciate if you address those before merging.
@@ -46,8 +70,27 @@ function ButtonsEdit( { | |||
} | |||
}, [ sizes ] ); | |||
|
|||
function onAddNextButton( selectedId ) { |
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.
Really minor, but using const onAddNextButton = ( selectedId ) => {
here instead would be slightly better as onAddNextButton
would be defined when this line is evaluated. function
declaration are ok but they're hoisted to the top of this react component so that might lead to inconsistencies.
Same for onDelete
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.
Personally, I prefer function declarations for non-callback functions, but I noticed that this function was only used as an argument for debounceAddNextButton
, so I decided to just have an onAddNextButton
variable set to the result of debounce
, with the function passed in as a callback.
I decided onDelete
didn't add much value (and might have actually just been complicating things by making your eyes jump back up the code just for a single-line function), so I just moved that function inline to where it was used.
44c2241
to
a6bdda0
Compare
Code changes looks properly, and do not expect any regression, however I will test it going through
Note: To test it properly I have to locally merge changes from |
Hey @lukewalczak 👋 I was working on a Buttons block PR and saw a possible regression from this PR but I want to double check with you. Looks like now the appender to add new buttons (when a Button is selected) is no longer showing. Is this expected?
|
Hey @geriux, are you sure that PR is a root of regression (I wouldn't consider it as a intentional behavior)? During testing I didn't notice it 🤔 |
@geriux probably, you're right and I had to overlooked that. Should I investigate that or you're on it currently? |
@lukewalczak fixed the issue mentioned above in this PR. |
Description
This PR refactors the Buttons block native edit implementation to use
useSelect
anduseDispatch
instead of their HOC counterparts.How has this been tested?
It hasn't. I need someone from the native mobile team to test out this PR and make sure everything works.
Checklist: