A fast and easy to use alert and dialog system for react-native-paper
install-quickstart-light.mp4
import { useAlerts } from "react-native-paper-fastalerts";
export default function HelloWorld() {
const { alert /*, confirm, warning, error, info */ } = useAlerts();
// or use: const alerts = useAlerts();
return (
<Button
onPress={() =>
alert({
// all options are optional and have sensible defaults
message: "What is the capital of Germany?",
okText: "Submit 🔥",
okAction(values) {
if (values[0] === "b") {
alert({ message: "Correct 🤗" });
} else {
return "Wrong 😅 Try again.";
}
},
fields: [
{
type: "radio",
data: [
{ key: "Berlin", value: "b" },
{ key: "Paris", value: "p" },
{ key: "London", value: "l" },
{ key: "Madrid", value: "m" },
],
},
],
})
}
>
Ask me a question!
</Button>
);
}