Skip to content

Commit 5f41a62

Browse files
joshdholtzclaude
andcommitted
Fix PaywallView styling timing issue with forced layout updates
Fixes an issue where styles applied to RevenueCatUI.Paywall component were not being applied immediately. The problem was that the paywall's native view setup was deferred until layoutSubviews, causing a timing issue with React Native's style application. This solution preserves the original view hierarchy timing while forcing immediate layout updates when React Native applies style changes. Changes: - Override reactSetFrame, setBounds, and setFrame methods - Call setNeedsLayout + layoutIfNeeded to force immediate layout updates - Preserve original view controller hierarchy setup timing This approach is safer than restructuring the view hierarchy timing as it: - Maintains SwiftUI environment context - Preserves safe area and layout guide behavior - Works with React Native's layout system Fixes #1366 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a718688 commit 5f41a62

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

react-native-purchases-ui/ios/PaywallViewWrapper.m

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,31 @@ - (instancetype)initWithPaywallViewController:(RCPaywallViewController *)paywall
3838
return self;
3939
}
4040

41-
4241
- (void)reactSetFrame:(CGRect)frame
4342
{
4443
NSLog(@"RNPaywalls - reactSetFrame: %@", NSStringFromCGRect(frame));
4544

4645
[super reactSetFrame: frame];
46+
47+
// Trigger layout update to ensure paywall view gets the new frame
48+
[self setNeedsLayout];
49+
[self layoutIfNeeded];
50+
}
51+
52+
- (void)setBounds:(CGRect)bounds {
53+
[super setBounds:bounds];
54+
55+
// Trigger layout update when bounds change
56+
[self setNeedsLayout];
57+
[self layoutIfNeeded];
58+
}
59+
60+
- (void)setFrame:(CGRect)frame {
61+
[super setFrame:frame];
62+
63+
// Trigger layout update when frame changes
64+
[self setNeedsLayout];
65+
[self layoutIfNeeded];
4766
}
4867

4968
- (void)layoutSubviews {

0 commit comments

Comments
 (0)