Skip to content

react-native Image w and h properties overwritten on web if using local image #1437

@Miyou

Description

@Miyou

Describe the bug

When importing Image from react-native, setting source to a local image e.g. source={require('assets/icon.png')} and setting e.g. h-20 and w-20 and rendering on web, the classes are correctly applied, but are overridden by the actual height and width of the image.

This does not seem to happen if setting source to an uri, and does not happen when rendering on iOS.

Reproduction
Stackblitz: https://stackblitz.com/edit/vitejs-vite-845c398o?file=my-expo-app%2Fapp%2Findex.tsx
Stackblitz render: https://76coth4vzab5pas.boltexpo.dev/

Expected behavior

The image should use the specified width from classNames, and not be overridden by actual image size.

Additional context

See dev tools:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions