Socket
Socket
Sign inDemoInstall

react-native-unicorn-modals

Package Overview
Dependencies
519
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-unicorn-modals

test


Version published
Maintainers
1
Created

Readme

Source

react-native-unicorn-modals

Easy way to implement custom modals in your application via imperative API with TypeScript support. Alerts, Menus or anything you want.

Requirements

This library requires you to install react-native-reanimated v2. Official documentation.

Setup

// Import initializer function and predefined component
import { createModalProvider, Alert } from 'react-native-unicorn-modals';

// Create Provider
const Provider = createModalProvider({ alert: Alert });

// Wrap app with Provider
const App = () => {
  return (
    <Provider>
      <MyScreen />
    </Provider>
  );
};

Usage

import { useModals } from 'react-native-unicorn-modals';

const MyScreen = () => {
  const modal = useModals();

  const openAlert = () => modal.show('alert', {
    title: 'Title',
    description: 'Description goes here.',
    buttons: [
      { onPress: () => { console.log('Confirm pressed') }, style: 'cancel', text: 'Cancel', secondary: true },
      { onPress: () => { console.log('Confirm pressed') }, style: 'default', text: 'Confirm' },
    ],
  });

  return (
    <TouchableOpacity onPress={openAlert}>
      <Text>Open alert</Text>
    </TouchableOpacity>
  )
};

Keywords

FAQs

Last updated on 28 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc