diff --git a/src/Image.tsx b/src/Image.tsx index de698943..e17364dd 100644 --- a/src/Image.tsx +++ b/src/Image.tsx @@ -176,6 +176,9 @@ const ImageInternal: CompoundedComponent = ({ // Keep order end React.useEffect(() => { + if (isError) { + setStatus('normal'); + } if (isCustomPlaceholder) { setStatus('loading'); } diff --git a/tests/fallback.test.tsx b/tests/fallback.test.tsx index ff1eb3f6..d6aefbd7 100644 --- a/tests/fallback.test.tsx +++ b/tests/fallback.test.tsx @@ -58,4 +58,19 @@ describe('Fallback', () => { expect(onErrorMock).toHaveBeenCalledTimes(1); }); + + it('should change image, not error', () => { + const wrapper = mount(); + act(() => { + wrapper.setProps({ + src: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ', + }); + jest.runAllTimers(); + wrapper.update(); + }); + expect(wrapper.find('.rc-image-img').prop('src')).toBe( + 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ', + ); + }); + });