docs: add image.preview.forceRender props (#37808)

* docs: add image.preview.forceRender props

* feat: add test case

* feat: edit test case

* feat: edit test case

* feat: edit test case
This commit is contained in:
binyellow 2022-10-10 12:08:42 +08:00 committed by GitHub
parent da5a3ddacb
commit 77a75c37cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -87,4 +87,21 @@ describe('Image', () => {
fireEvent.click(container.querySelector('.ant-image')!);
expect(baseElement.querySelector('.container')?.children.length).not.toBe(0);
});
it('Preview forceRender props', async () => {
const onLoadCb = jest.fn();
const PreviewImage: React.FC = () => (
<Image
preview={{
visible: false,
src,
forceRender: true,
}}
/>
);
const { baseElement } = render(<PreviewImage />);
expect(baseElement.querySelector('.ant-image-preview-root')).not.toBe(null);
baseElement.querySelector('.ant-image-preview-img')?.addEventListener('load', onLoadCb);
fireEvent.load(baseElement.querySelector('.ant-image-preview-img')!);
expect(onLoadCb).toHaveBeenCalled();
});
});

View File

@ -40,6 +40,7 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg
maskClassName?: string; // v4.11.0
current?: number; // v4.12.0 仅支持 PreviewGroup
countRender?: (current: number, total: number) => string // v4.20.0 仅支持 PreviewGroup
forceRender?: boolean;
}
```