Try using createElement for renderAppender render prop#15259
Merged
Conversation
talldan
commented
Apr 30, 2019
| return ( | ||
| <div className="block-list-appender"> | ||
| { createElement( renderAppender ) } | ||
| <CustomAppender /> |
Contributor
Author
There was a problem hiding this comment.
@aduth - this is another alternative since JSX desugars to createElement.
Member
There was a problem hiding this comment.
@aduth - this is another alternative since JSX desugars to
createElement.
I hadn't thought about that, but yes, I think that'd make for a fine (preferred) alternative.
This was referenced Apr 30, 2019
aduth
approved these changes
May 2, 2019
Member
aduth
left a comment
There was a problem hiding this comment.
A nice simple improvement 👍 Thanks for running with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR serves as an iteration on #14241 and #14943.
As mentioned in a couple of comments by @aduth, using
createElementinstead of the traditional function call when rendering a render prop offers more flexibility for the implementor of the render prop. The implementor can use the traditional render prop style:as well as using a simpler style without the need for the wrapping function:
The only downside I can see is that if parameters were added to
renderAppender, they'd need to be expressed as props:instead of a plain argument:
which is inconsistent with other render props.
How has this been tested?
Types of changes
Non-breaking refactor
Checklist: