From 380fc8334b45bf3f7e0b207748df26ee4b0814bb Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Mon, 18 May 2026 12:20:24 -0700 Subject: [PATCH] Fix infinite recomposition in `Text.foregroundStyle(LinearGradient())` Fixes https://github.com/skiptools/skip-ui/issues/437 --- Sources/SkipUI/SkipUI/Graphics/Gradient.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SkipUI/SkipUI/Graphics/Gradient.swift b/Sources/SkipUI/SkipUI/Graphics/Gradient.swift index f50a467b..826cc779 100644 --- a/Sources/SkipUI/SkipUI/Graphics/Gradient.swift +++ b/Sources/SkipUI/SkipUI/Graphics/Gradient.swift @@ -141,7 +141,9 @@ public struct LinearGradient : ShapeStyle, Renderable { @Composable override func asBrush(opacity: Double, animationContext: ComposeContext?) -> Brush? { let stops = gradient.colorStops(opacity: opacity) - return LinearGradientShaderBrush(colorStops: stops, startPoint: startPoint, endPoint: endPoint) + return remember(gradient, startPoint, endPoint, opacity) { + LinearGradientShaderBrush(colorStops: stops, startPoint: startPoint, endPoint: endPoint) + } } private struct LinearGradientShaderBrush: ShaderBrush {