-
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 appender to use the render function instead of a component instance #29911
base: trunk
Are you sure you want to change the base?
Refactor appender to use the render function instead of a component instance #29911
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @renatho! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
I don't think this would work if renderAppender used a class component. So it'd be a breaking change. (edit: although two things - the renderAppender docs are wrong, and this PR makes it works as the docs suggest. It might also be possible to update this to work with class components). |
I've updated the docs to match how it currently works - #29925. |
Ah, that's true. I'm closing it, and thank you for updating the documentation! EDIT: since we support the |
Reopening this PR since we don't have a way to pass custom props to the appender unless using a function. I made a refactor introducing a new boolean property I thought of using a separate prop for the render prop, but probably it would get more confusing. |
7874569
to
875a6f3
Compare
Hi @talldan! Have you seen these changes? While that, we're using |
If there's no issue with the current approach, is it worth adding an additional prop (public API) for this? |
I think the problem with the current approach is that in these cases we're trusting in the But since it doesn't seem a good practice, my opinion would be that we should introduce a solution for these cases (needing to use local props or states to create the appender). 😊 Some solution like this new prop would also make more transparent that the |
I can see the shortcomings with If there's a new prop, I think it'd be best to deprecate
|
Hey there! Honestly, I suggested the render prop because the current prop naming ( But I think the render prop is not needed here for now because we don't send any prop for the component. It could be helpful for the future if we want add arguments coming from the So maybe for now we could just deprecate the property as suggested, and just send a rendered component as const appender = <MyAppender { ...myProps } />
return <InnerBlocks appender={ appender } /> WDYT? |
c928319
to
1e0c7b4
Compare
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.
I implemented the new approach. I think deprecating the renderAppender
and making the appender
be the new prop, as suggested, made it much cleaner. =)
packages/block-editor/src/components/block-list-appender/index.js
Outdated
Show resolved
Hide resolved
043a0b9
to
2a792e3
Compare
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.
I've tested this on iOS and Android using Column and Group blocks and it's looking good. I just have a comment about possible loss of a previous performance improvement.
@talldan, I think after the mobile review, we're good to go ahead with this. WDYT? |
be31fbc
to
a59600c
Compare
Rebased to fix the new conflicts, and updated the deprecated versions! ;) |
The new prop is the rendered appender. This commit also deprecates the renderAppender prop.
Appender explicitly supports `false` as an option now.
a59600c
to
b67f39e
Compare
Description
This deprecates the
renderAppender
prop in theInnerBlocks
, introducing a newappender
prop for this purpose. The difference is that theappender
now is a rendered component instead of the component function/class.If the
appender
isnull
, nothing is rendered.If the
appender
isundefined
the default is rendered.More details here.
How has this been tested?
Types of changes
It's basically a refactor that should not impact in anything.
Checklist: