-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the issue
Image component changes state onLoad event, that causes lots of unnecessary re-renders if defaultSource is empty:
these lines:
react-native-web/packages/react-native-web/src/exports/Image/index.js
Lines 282 to 299 in 3c27dec
| 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
Additional comments
Here is a patch (if we ignore those state changes nothing changes image will be displayed as it was before)