Skip to content

[Feature request] Add a way to add style to <img /> #2139

Closed as duplicate

Description

@kopax-polyconseil

Using react-native-web 0.17.1, we are having a BlurImage on which we want to apply a transform: scale(1.1) style.

Looking at the source code, the current API doesn't allow it.

Screenshots

*Web - [without style on img] *Web - [with style on img]
image image

Possible resolution

https://github.com/pass-culture/pass-culture-app-native/pull/1731/files#diff-64d21386a1fda6922603e6d64ab36adbf1b8143e014a6bb76a3f29ffd4387507

Would you be up for adding such a feature in react-native-web future version?

Thanks a lot.

Activity

  1. added this to the 0.18: Image milestone on Sep 27, 2021
  2. yuxizhe commented on Jun 28, 2022

    @yuxizhe
    Contributor

    @kopax-polyconseil why not use style prop <Image style={{transform: 'scale(1.1)'}}>

  3. kopax-polyconseil commented on Jun 28, 2022

    @kopax-polyconseil
    Author

    @kopax-polyconseil why not use style prop <Image style={{transform: 'scale(1.1)'}}>

    I think I tried, at the time I wrote. Does it work now ?

  4. kopax-polyconseil commented on Jul 18, 2022

    @kopax-polyconseil
    Author

    @yuxizhe I just checked and this is what TypeScripts tells me:

    TS2769: No overload matches this call.   Overload 1 of 2, '(props: Omit<Omit<ImageProps & RefAttributes<Image> & { height: number; width: number; }, never> & Partial<Pick<ImageProps & RefAttributes<Image> & { ...; }, never>>, "theme"> & { ...; } & { ...; } & { ...; }): ReactElement<...>', gave the following error.     Type '{ transform: string; }' is not assignable to type 'StyleProp<ImageStyle>'.       Types of property 'transform' are incompatible.         Type 'string' is not assignable to type '(PerpectiveTransform | RotateTransform | RotateXTransform | RotateYTransform | RotateZTransform | ... 7 more ... | MatrixTransform)[] | undefined'.   Overload 2 of 2, '(props: StyledComponentPropsWithAs<typeof Image, DefaultTheme, { height: number; width: number; }, never, typeof Image, typeof Image>): ReactElement<...>', gave the following error.     Type '{ transform: string; }' is not assignable to type 'StyleProp<ImageStyle>'.       Types of property 'transform' are incompatible.         Type 'string' is not assignable to type '(PerpectiveTransform | RotateTransform | RotateXTransform | RotateYTransform | RotateZTransform | ... 7 more ... | MatrixTransform)[] | undefined'.

    So far, we have to stick to our patch-package until this is properly fixed.

  5. necolas commented on Jul 18, 2022

    @necolas
    Owner

    That's because (as explained in the ts error message you pasted) you're passing a transform string where React Native expects an object

  6. kopax-polyconseil commented on Aug 1, 2022

    @kopax-polyconseil
    Author

    @necolas the format was given by @yuxizhe in the previous message. How should I write to redo the test ?

  7. zoontek commented on Nov 6, 2026

    @zoontek
    Collaborator

    Thanks for the report. #1786 lists this request under its "Support for CSS like backgroundBlendMode" item. I'm closing this issue as a duplicate of #1786. Please follow that issue for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions