You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second image gets opaque after a few seconds (the DelayedImage component gets rerendered with the new state).
Actual result:
The image stays translucent despite the new state that should make it opaque.
I reproduced the bug with React 16.8.2 in Safari 12.0.3 and Chrome 72.0.3626.109 on macOS 10.14.3 (didn't try other versions).
More details about the example
The DelayedImage component is an image that gets translucent while being loaded. The information about whether the image is loading or loaded is stored in a state using the useState hook. The other state hook is used to check whether the image URL has changed (like in the FAQ example).
When the component is rendered for the first time, it works as expected: it is translucent while the image is loading and opaque after the image is loaded. When the src prop is changed (by clicking the "Set picture 2" button), the image gets translucent but doesn't get opaque when it's loaded.
According to the console messages, the correct value (isLoaded === true) is set to the state but React doesn't rerenders the component. React rerenders the component with the correct state when any other DelayedImage props is changed (by clicking the last button or changing a prop using Redux Dev Tools).
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
This is a bug. I've spent a lot of time trying to localize the bug and have ended with the following minimal example:
Live demo
Steps to reproduce:
Expected result:
The second image gets opaque after a few seconds (the
DelayedImage
component gets rerendered with the new state).Actual result:
The image stays translucent despite the new state that should make it opaque.
I reproduced the bug with React 16.8.2 in Safari 12.0.3 and Chrome 72.0.3626.109 on macOS 10.14.3 (didn't try other versions).
More details about the example
The
DelayedImage
component is an image that gets translucent while being loaded. The information about whether the image is loading or loaded is stored in a state using theuseState
hook. The other state hook is used to check whether the image URL has changed (like in the FAQ example).When the component is rendered for the first time, it works as expected: it is translucent while the image is loading and opaque after the image is loaded. When the
src
prop is changed (by clicking the "Set picture 2" button), the image gets translucent but doesn't get opaque when it's loaded.According to the console messages, the correct value (
isLoaded === true
) is set to the state but React doesn't rerenders the component. React rerenders the component with the correct state when any otherDelayedImage
props is changed (by clicking the last button or changing a prop using Redux Dev Tools).The text was updated successfully, but these errors were encountered: