Commit 2361189
Deprecate ImageBackground (#57412)
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:
```tsx
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
Pull Request resolved: #57412
Test Plan:
- `deprecated` shows a strikethrough on `ImageBackground` in editors.
- Importing/rendering `ImageBackground` logs the deprecation warning once.
Reviewed By: javache
Differential Revision: D110484567
Pulled By: cortinico
fbshipit-source-id: 0f70893a0680b9bb34e1442bfef41e9210c08d071 parent 803456d commit 2361189
3 files changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
342 | 348 | | |
343 | 349 | | |
344 | 350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
| |||
0 commit comments