Fix multiple calls to image `onLoadingComplete()` (#33474)
The image prop `onLoadingComplete()` was unexpectedly called multiple times because it uses a [callback ref](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs). This could lead to an infinite loop if `onLoadingComplete()` calls `setState()` as demonstrated in the updated test. The solution is to handle refs with `useRef()` and `useEffect` so `onLoadingComplete()` is called at most once per component instance. - Fixes #33463
Showing
Please
register
or
sign in
to comment