-
Notifications
You must be signed in to change notification settings - Fork 1
Add customItemsRenderer prop #152
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ const Tree = props => { | |
itemsRenderer: Items = ItemsRenderer, | ||
forwardIconRenderer, | ||
treeContainerRenderer: TreeContainer = TreeContainerRenderer, | ||
customItemsRenderer, | ||
selectedItem | ||
} = props; | ||
|
||
|
@@ -94,20 +95,29 @@ const Tree = props => { | |
inputIconRenderer={inputIconRenderer} | ||
clearIconRenderer={clearIconRenderer} | ||
/> | ||
<Items styles={styles} getStyles={getStyles} height={itemsHeight}> | ||
{leaves && | ||
leaves.length > 0 && | ||
leaves.map(item => ( | ||
<Item | ||
getStyles={getStyles} | ||
searchTerm={searchTerm} | ||
item={item} | ||
onClick={onClick} | ||
forwardIconRenderer={forwardIconRenderer} | ||
selectedItem={selectedItem} | ||
/> | ||
))} | ||
</Items> | ||
{customItemsRenderer ? ( | ||
React.cloneElement(customItemsRenderer, { | ||
...props, | ||
leaves, | ||
searchTerm, | ||
onClick | ||
}) | ||
) : ( | ||
<Items styles={styles} getStyles={getStyles} height={itemsHeight}> | ||
{leaves && | ||
leaves.length > 0 && | ||
leaves.map(item => ( | ||
<Item | ||
getStyles={getStyles} | ||
searchTerm={searchTerm} | ||
item={item} | ||
onClick={onClick} | ||
forwardIconRenderer={forwardIconRenderer} | ||
selectedItem={selectedItem} | ||
Comment on lines
+116
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't want to pass these two? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as I see selected Item we pass externally There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ForwardIconRenderer the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's important we maintain the same API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a ping on this so that we can merge There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
/> | ||
))} | ||
</Items> | ||
)} | ||
{leaves && leaves.length === 0 && ( | ||
<NoResults | ||
height={itemsHeight} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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'm not sure we should just pass the props (I'm talking about ...props), the props are meant for tree.
As any custom renderer, you can OTHER props externally when you do something like
Unless you mean yo pass something like
In which case you also need to create the component in the tree and you can still pass props using something like
Hope my comment is understandable.