Is there an existing issue for this?
Describe the issue
Image component changes state onLoad event, that causes lots of unnecessary re-renders if defaultSource is empty:
these lines:
|
updateState(LOADING); |
|
if (onLoadStart) { |
|
onLoadStart(); |
|
} |
|
|
|
requestRef.current = ImageLoader.load( |
|
uri, |
|
function load(e) { |
|
updateState(LOADED); |
|
if (onLoad) { |
|
onLoad(e); |
|
} |
|
if (onLoadEnd) { |
|
onLoadEnd(); |
|
} |
|
}, |
|
function error() { |
|
updateState(ERRORED); |
Expected behavior
No set state inside Image component if defaultSource is empty
Steps to reproduce
- Render the image:
<Image defaultSource={null} source={...} />
- Open a React Profile to check renders
Test case
https://codesandbox.io/skip
Additional comments
Here is a patch (if we ignore those state changes nothing changes image will be displayed as it was before)
react-native-web+0.17.7+001+no-image-state-change.txt
Is there an existing issue for this?
Describe the issue
Image component changes state onLoad event, that causes lots of unnecessary re-renders if
defaultSourceis empty:these lines:
react-native-web/packages/react-native-web/src/exports/Image/index.js
Lines 282 to 299 in 3c27dec
Expected behavior
No set state inside Image component if
defaultSourceis emptySteps to reproduce
<Image defaultSource={null} source={...} />Test case
https://codesandbox.io/skip
Additional comments
Here is a patch (if we ignore those state changes nothing changes image will be displayed as it was before)
react-native-web+0.17.7+001+no-image-state-change.txt