diff --git a/components/badge/Badge.jsx b/components/badge/Badge.jsx
index 846e97d83..2ca8c5626 100644
--- a/components/badge/Badge.jsx
+++ b/components/badge/Badge.jsx
@@ -21,7 +21,7 @@ const BadgeProps = {
scrollNumberPrefixCls: PropTypes.string,
status: PropTypes.oneOf(['success', 'processing', 'default', 'error', 'warning']),
color: PropTypes.string,
- text: PropTypes.string,
+ text: PropTypes.any,
offset: PropTypes.array,
numberStyle: PropTypes.object.def(() => ({})),
title: PropTypes.string,
@@ -110,7 +110,7 @@ export default {
},
renderStatusText(prefixCls) {
- const { text } = this.$props;
+ const text = getComponent(this, 'text');
const hidden = this.isHidden();
return hidden || !text ? null : {text};
},
@@ -173,10 +173,10 @@ export default {
prefixCls: customizePrefixCls,
scrollNumberPrefixCls: customizeScrollNumberPrefixCls,
status,
- text,
color,
} = this;
+ const text = getComponent(this, 'text');
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('badge', customizePrefixCls);
const scrollNumberPrefixCls = getPrefixCls('scroll-number', customizeScrollNumberPrefixCls);
diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap
index 2939e5279..4afa84dc8 100644
--- a/components/badge/__tests__/__snapshots__/index.test.js.snap
+++ b/components/badge/__tests__/__snapshots__/index.test.js.snap
@@ -44,3 +44,5 @@ exports[`Badge should support offset when count is a VueNode 1`] = `
head
`;
+
+exports[`Badge text works with vnode 1`] = `hello`;
diff --git a/components/badge/__tests__/index.test.js b/components/badge/__tests__/index.test.js
index cf93f59d1..aa27ec16b 100644
--- a/components/badge/__tests__/index.test.js
+++ b/components/badge/__tests__/index.test.js
@@ -136,4 +136,14 @@ describe('Badge', () => {
});
expect(wrapper.html()).toMatchSnapshot();
});
+
+ it('text works with vnode', () => {
+ const wrapper = mount({
+ render() {
+ return hello} />;
+ },
+ });
+
+ expect(wrapper.html()).toMatchSnapshot();
+ });
});
diff --git a/types/badge.d.ts b/types/badge.d.ts
index 1b603e7ee..96c5a6fe8 100644
--- a/types/badge.d.ts
+++ b/types/badge.d.ts
@@ -52,7 +52,7 @@ export declare class Badge extends AntdComponent {
* If status is set, text sets the display text of the status dot
* @type string
*/
- text?: string;
+ text?: VNodeChild | JSX.Element;
/**
* sets the display style of the status dot