Skip to content

Commit 145f578

Browse files
committed
[fix] Image SSR hydration warnings
React doesn't currently provide an API for defining SSR-safe IDs, so we have to suppress the hydration warnings that occur. The 'useOpaqueIdentifier' hook is intended to support this use case but is not currently a public API and development has been paused. facebook/react#17322. Close #1375
1 parent 5a5c8e5 commit 145f578

File tree

1 file changed

+2
-2
lines changed
  • packages/react-native-web/src/exports/Image

1 file changed

+2
-2
lines changed

packages/react-native-web/src/exports/Image/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function createTintColorSVG(tintColor, id) {
3535
return tintColor && id != null ? (
3636
<svg style={{ position: 'absolute', height: 0, visibility: 'hidden', width: 0 }}>
3737
<defs>
38-
<filter id={`tint-${id}`}>
38+
<filter id={`tint-${id}`} suppressHydrationWarning={true}>
3939
<feFlood floodColor={`${tintColor}`} key={tintColor} />
4040
<feComposite in2="SourceAlpha" operator="atop" />
4141
</filter>
@@ -46,7 +46,6 @@ function createTintColorSVG(tintColor, id) {
4646

4747
function getFlatStyle(style, blurRadius, filterId) {
4848
const flatStyle = { ...StyleSheet.flatten(style) };
49-
5049
const { filter, resizeMode, shadowOffset, tintColor } = flatStyle;
5150

5251
// Add CSS filters
@@ -284,6 +283,7 @@ const Image = forwardRef<ImageProps, *>((props, ref) => {
284283
{ backgroundImage, filter },
285284
backgroundSize != null && { backgroundSize }
286285
]}
286+
suppressHydrationWarning={true}
287287
/>
288288
{hiddenImage}
289289
{createTintColorSVG(tintColor, filterRef.current)}

0 commit comments

Comments
 (0)