react-native-simplest-alert
v1.0.6
Published
Just call a function to show your alert. No need for jsx. Works on ios, android, and the web. Supports multi alerts at the same time.
Downloads
3
Maintainers
Readme
React Native Simplest Alert
Display an alert with a simple function call:
showAlert({
header: 'Some Title',
body: 'This is the body of the message.',
});
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',
});
}