rsnext/packages
Steven c879fce0d4
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
2022-01-20 15:29:34 +00:00
..
create-next-app v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
eslint-config-next v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
eslint-plugin-next v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next Fix multiple calls to image onLoadingComplete() (#33474) 2022-01-20 15:29:34 +00:00
next-bundle-analyzer v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-codemod v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-env v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-mdx v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-plugin-storybook v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-polyfill-module v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-polyfill-nomodule v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
next-swc v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
react-dev-overlay v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
react-refresh-utils v12.0.9-canary.4 2022-01-20 09:57:25 +01:00