How to display toast message in react native

React Native now has built-in API Alert which works both on IOS and Android. https://reactnative.dev/docs/alert


Can use below notifyMessage to show toast message:

import {
      ToastAndroid,
      Platform,
      AlertIOS,
    } from 'react-native';

function notifyMessage(msg: string) {
  if (Platform.OS === 'android') {
    ToastAndroid.show(msg, ToastAndroid.SHORT)
  } else {
    AlertIOS.alert(msg);
  }
}

OR

Use react-native-simple-toast in both iOS & Android.

import Toast from 'react-native-simple-toast';

Toast.show('This is a toast.');
Toast.show('This is a long toast.', Toast.LONG);

Tags:

React Native