Skip to content

adrianschubek/react-native-paper-fastalerts

Repository files navigation

react-native-paper-fastalerts

npm

A fast and easy to use alert and dialog system for react-native-paper

fastalerts.adriansoftware.de

Demo

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>
  );
}