Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

AlertIOS undefined errors (React Native)

$
0
0

I'm trying to use AlertIOS in a brand new React Native project, but for some reason I'm getting undefined-related errors.

The relevant parts of the code:

import { AlertIOS } from 'react-native';

// Callback for a button press
const _alert = () => {
  AlertIOS.alert('title', 'text')
}

If I'm not in debug mode, after clicking the button I get the error undefined is not an object (evaluating '_reactNative.AlertIOS.alert').

When debugging, the error changes to Cannot read property alert of undefined and AlertIOS has the value shown in the print below, which doesn't seem right.

Also, if I just use Alert.alert, it works (obviously changing the import).

enter image description here


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>