1.0.6 • Published 2 years ago

react-native-simplest-alert v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native Simplest Alert

Display an alert with a simple function call:

showAlert({
  header: 'Some Title',
  body: 'This is the body of the message.',
});

Screen Capture Gif

No Need for JSX or "isAlertShown" props.


Optionally, you can pass an onClose:

showAlert({
  header: 'Posted!',
  body: 'Your post was posted. Click OK to proceed',
  onClose: () => navigation.navigate("SomePage"),
});

How To Use

Wrap your app inside an <AlertProvider> tag:

import { AlertProvider } from 'react-native-simplest-alert';

export default function App() {
  return (
    <AlertProvider>
      {/* your code... */}
    </AlertProvider>
  );
}

Anywhere in your application:

import { showAlert } from 'react-native-simplest-alert';
  
function onPanic() {
  showAlert({
    header: 'Troll! In the Dungeon!',
    body: 'Thought you ought to know',
    backgroundColor: 'darkred',
    buttonBgColor: 'red',
  });
}