Skip to content

Deprecate ImageBackground#57412

Open
zoontek wants to merge 1 commit into
react:mainfrom
zoontek:deprecate-image-background
Open

Deprecate ImageBackground#57412
zoontek wants to merge 1 commit into
react:mainfrom
zoontek:deprecate-image-background

Conversation

@zoontek

@zoontek zoontek commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary:

Deprecates ImageBackground as part of the effort to keep core lean. It is a thin wrapper around a View and an Image, and can easily be replaced by composing a View with an absolutely positioned Image and layering children on top:

import type { ReactNode, Ref } from "react";
import {
  Image,
  StyleSheet,
  View,
  type ImageProps,
  type ViewProps,
} from "react-native";

type ImageBackgroundProps = Omit<ImageProps, "style"> & {
  children?: ReactNode;
  ref?: Ref<View>;
  style?: ViewProps["style"];
};

export const ImageBackground = ({
  children,
  importantForAccessibility,
  ref,
  style,
  ...props
}: ImageBackgroundProps) => {
  const { height, width } = StyleSheet.flatten(style);

  return (
    <View
      ref={ref}
      accessibilityIgnoresInvertColors={true}
      importantForAccessibility={importantForAccessibility}
      style={style}
    >
      <Image
        {...props}
        importantForAccessibility={importantForAccessibility}
        style={[StyleSheet.absoluteFill, { height, width }]}
      />
      {children}
    </View>
  );
};

Changelog:

[GENERAL] [DEPRECATED] - Deprecate ImageBackground, use a View with an absolutely positioned Image instead

Test Plan:

  • deprecated shows a strikethrough on ImageBackground in editors.
  • Importing/rendering ImageBackground logs the deprecation warning once.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 2, 2026
@facebook-github-tools facebook-github-tools Bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jul 2, 2026
@meta-codesync

meta-codesync Bot commented Jul 2, 2026

Copy link
Copy Markdown

@cortinico has imported this pull request. If you are a Meta employee, you can view this in D110484567.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant