Patch Changes
-
#6041
5ec842bThanks @brianatdetections! - Fix race condition in use-image hook that caused cached images to remain invisible (stuck at opacity-0) on Firefox and Safari.Root Cause:
Event handlers (onload/onerror) were attached AFTER setting the imagesrc. For cached images, the browser firesonloadsynchronously whensrcis set, causing the event to be missed. This is particularly prevalent in Firefox and Safari due to their JavaScript execution timing characteristics.Solution:
- Attach
onload/onerrorhandlers BEFORE settingsrc - Check both
naturalWidthANDnaturalHeight(per CodeRabbit review feedback on #4523) - Handle synchronous error callbacks for failed cached images
- Include
ignoreFallbackin useCallback dependencies to prevent stale closures when prop changes dynamically - Add comprehensive test coverage including synchronous callback scenarios and dynamic
ignoreFallbackchanges
- Attach
-
Updated dependencies [
5ec842b]:- @heroui/use-image@2.1.14