Skip to content

Commit f06a6e1

Browse files
committed
fix: present fixture alert after React commit
1 parent 64f1511 commit f06a6e1

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

examples/test-app/src/screens/AutomationLabScreen.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,25 @@ export function AutomationLabScreen(props: {
8484
};
8585
}, []);
8686

87+
useEffect(() => {
88+
if (alertResult !== 'opened') return;
89+
90+
// The opened canary is committed before this effect; the smoke step separately waits for native presentation.
91+
Alert.alert('Automation confirmation', 'Choose either result to update the visible canary.', [
92+
{
93+
style: 'cancel',
94+
text: 'Cancel',
95+
onPress: () => setAlertResult('cancelled'),
96+
},
97+
{
98+
text: 'OK',
99+
onPress: () => setAlertResult('accepted'),
100+
},
101+
]);
102+
}, [alertResult]);
103+
87104
function showAutomationAlert() {
88105
setAlertResult('opened');
89-
setTimeout(() => {
90-
// The opened canary proves JS ran; the smoke step separately waits for native presentation.
91-
Alert.alert('Automation confirmation', 'Choose either result to update the visible canary.', [
92-
{
93-
style: 'cancel',
94-
text: 'Cancel',
95-
onPress: () => setAlertResult('cancelled'),
96-
},
97-
{
98-
text: 'OK',
99-
onPress: () => setAlertResult('accepted'),
100-
},
101-
]);
102-
});
103106
}
104107

105108
async function requestMicrophonePermission() {

0 commit comments

Comments
 (0)