Major Changes
-
#3252
121207eThanks
@github-actions! - Breaking: Removeapi.setSrc.You own the image
src, the machine observes the rendered image and owns its loading lifecycle.setSrcwrote the
srcattribute of the image you rendered, making it the only API method in the library that mutates a
consumer-rendered element. It also leftsrcSetand<picture>untouched, so the displayed image did not always
change.Migration
Setting the source: update
srcon the image you render. The machine reacts the same way, resetting toloading
and then toloadedorerror.- api.setSrc(nextSrc) + setSrc(nextSrc) // your own state, applied to the image you render
const [src, setSrc] = useState(initialSrc) <img alt="" src={src} {...api.getImageProps()} />
Without framework state, set it on the element directly. This is what
setSrcdid, and it works forsrcSetand
<picture>too:- api.setSrc(nextSrc) + imageEl.src = nextSrc
Unchanged:
api.setLoaded()andapi.setError(), for images loaded by something that does not fireloadand
erroron the element itself.