From 816cf1052482389739cfb518a480ce0d6f19291f Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Wed, 7 Dec 2022 23:32:04 +0800 Subject: [PATCH] fix: update demo (#39366) * fix: update demo * Update components/qrcode/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> * Update index.test.tsx Co-authored-by: MadCcc <1075746765@qq.com> --- components/qrcode/__tests__/index.test.tsx | 9 +++++++++ components/qrcode/demo/customSize.tsx | 1 + components/qrcode/demo/icon.tsx | 1 + components/qrcode/index.tsx | 8 ++++++++ components/qrcode/interface.ts | 1 - 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/qrcode/__tests__/index.test.tsx b/components/qrcode/__tests__/index.test.tsx index 6de938dab5..8cd91d3ce0 100644 --- a/components/qrcode/__tests__/index.test.tsx +++ b/components/qrcode/__tests__/index.test.tsx @@ -79,4 +79,13 @@ describe('QRCode test', () => { 'ant-qrcode-borderless', ); }); + + it('should console Error when icon exist && errorLevel is `L`', () => { + const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + render(); + expect(errSpy).toHaveBeenCalledWith( + 'Warning: [antd: QRCode] ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.', + ); + errSpy.mockRestore(); + }); }); diff --git a/components/qrcode/demo/customSize.tsx b/components/qrcode/demo/customSize.tsx index 35b06fff45..d1ee8f6fa9 100644 --- a/components/qrcode/demo/customSize.tsx +++ b/components/qrcode/demo/customSize.tsx @@ -36,6 +36,7 @@ const App: React.FC = () => { ( diff --git a/components/qrcode/index.tsx b/components/qrcode/index.tsx index eec3f9e27f..b47d7da928 100644 --- a/components/qrcode/index.tsx +++ b/components/qrcode/index.tsx @@ -59,6 +59,14 @@ const QRCode: React.FC = (props) => { return null; } + if (process.env.NODE_ENV !== 'production') { + warning( + !(icon && errorLevel === 'L'), + 'QRCode', + 'ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.', + ); + } + const cls = classNames(prefixCls, className, hashId, { [`${prefixCls}-borderless`]: !bordered, }); diff --git a/components/qrcode/interface.ts b/components/qrcode/interface.ts index 3371e02035..bebeeacd78 100644 --- a/components/qrcode/interface.ts +++ b/components/qrcode/interface.ts @@ -12,7 +12,6 @@ interface ImageSettings { interface QRProps { value: string; size?: number; - level?: string; color?: string; style?: CSSProperties; includeMargin?: boolean;