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>
pull/39250/head^2
lijianan 2 years ago committed by GitHub
parent a836a3a3fe
commit 816cf10524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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(<QRCode value="test" icon="test" errorLevel="L" />);
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();
});
});

@ -36,6 +36,7 @@ const App: React.FC = () => {
</Button>
</Button.Group>
<QRCode
errorLevel="H"
size={size}
iconSize={size / 4}
value="https://ant.design/"

@ -3,6 +3,7 @@ import { QRCode } from 'antd';
const App: React.FC = () => (
<QRCode
errorLevel="H"
value="https://ant.design/"
icon="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
/>

@ -59,6 +59,14 @@ const QRCode: React.FC<QRCodeProps> = (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,
});

@ -12,7 +12,6 @@ interface ImageSettings {
interface QRProps {
value: string;
size?: number;
level?: string;
color?: string;
style?: CSSProperties;
includeMargin?: boolean;

Loading…
Cancel
Save