Skip to content

Image: ignore changes to 'onLoad' callback if image already loaded #2025

@oste

Description

@oste

The problem
The Image component reloads on each rerender.

How to reproduce
https://codesandbox.io/s/happy-mountain-i2eol?file=/src/App.js

Steps to reproduce:

  1. Add the Image tag to your component
  2. Add the onLoad property to the Image tag
  3. set state in the onLoad property

Expected behavior
It would work similar to the img tag. Here is the same code sandbox with <Image swapped out for <img src= https://codesandbox.io/s/happy-bell-i4v5q?file=/src/App.js

Environment (include versions). Did this work in previous versions?
Please see code sandbox. It did not work differently in a previous verion that I am aware of.

Disclaimer: My expectations and use case might not align with react native web. However I am not sure how to successfully set state in onLoad without a duplicate render.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions