Skip to content

Commit 8906b3f

Browse files
authored
Merge pull request #134 from matpaul/alerts-rework
Fix #85, callback associated with button in Alert.alert not working
2 parents 63c6b78 + af2c417 commit 8906b3f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

React/Modules/RCTAlertManager.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ - (void)invalidate
9999
[_alertCallbacks addObject:callback ?: ^(__unused id unused) {}];
100100
[_alertButtonKeys addObject:buttonKeys];
101101

102-
[alertView runModal];
102+
NSInteger buttonPosition = [alertView runModal];
103+
NSString *buttonKey = [buttonKeys objectAtIndex: buttonPosition - NSAlertFirstButtonReturn];
104+
105+
callback(@[buttonKey]);
103106
}
104107

105108
@end

0 commit comments

Comments
 (0)