-
-
Notifications
You must be signed in to change notification settings - Fork 260
feat: Support custom rendering #792
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
d45697e
b0829a4
e9f46a0
743803f
281afbb
9ad16df
a438a2e
8993061
6a22b41
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 |
---|---|---|
|
@@ -228,5 +228,40 @@ describe('MenuItem', () => { | |
|
||
expect(container.querySelector('li')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should wrap originNode with custom render', () => { | ||
const { container } = render( | ||
<Menu | ||
itemsRender={(originNode, item) => { | ||
if (item.type === 'item') { | ||
return ( | ||
<a href="https://ant.design" target="_blank" rel="noopener noreferrer"> | ||
{originNode} | ||
</a> | ||
); | ||
} | ||
return originNode; | ||
}} | ||
items={[ | ||
{ | ||
key: 'mail', | ||
type: 'item', | ||
label: 'Navigation One', | ||
}, | ||
{ | ||
key: 'app', | ||
label: 'Navigation 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. render 放 item 里意义不大,和直接写 label 没区别。用户期望的是可以在顶层统一配置 itemRender 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. <Menu itemRender={...} /> 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. done |
||
{ | ||
key: 'upload', | ||
label: 'Upload File', | ||
}, | ||
]} | ||
/>, | ||
); | ||
|
||
const link = container.querySelector('a'); | ||
expect(link).toHaveAttribute('href', 'https://ant.design'); | ||
}); | ||
}); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.