Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@expo/react-native-action-sheet

Package Overview
Dependencies
Maintainers
11
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/react-native-action-sheet

A cross-platform ActionSheet for React Native

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
11
Created

What is @expo/react-native-action-sheet?

@expo/react-native-action-sheet is a library that provides a customizable ActionSheet component for React Native applications. It allows developers to present a list of options to the user in a modal dialog, which can be used for various purposes such as selecting an item, confirming an action, or displaying additional options.

What are @expo/react-native-action-sheet's main functionalities?

Displaying an ActionSheet

This feature allows you to display an ActionSheet with a list of options. The user can select an option, and the selected option's index is returned in the callback function.

import React from 'react';
import { View, Button } from 'react-native';
import { useActionSheet } from '@expo/react-native-action-sheet';

const App = () => {
  const { showActionSheetWithOptions } = useActionSheet();

  const onOpenActionSheet = () => {
    const options = ['Option 1', 'Option 2', 'Cancel'];
    const cancelButtonIndex = 2;

    showActionSheetWithOptions(
      {
        options,
        cancelButtonIndex,
      },
      (buttonIndex) => {
        // Handle button press
        console.log('Selected option:', buttonIndex);
      }
    );
  };

  return (
    <View>
      <Button title="Open ActionSheet" onPress={onOpenActionSheet} />
    </View>
  );
};

export default App;

Customizing ActionSheet Options

This feature allows you to customize the ActionSheet options, including setting a destructive button (e.g., for delete actions) and a cancel button.

import React from 'react';
import { View, Button } from 'react-native';
import { useActionSheet } from '@expo/react-native-action-sheet';

const App = () => {
  const { showActionSheetWithOptions } = useActionSheet();

  const onOpenActionSheet = () => {
    const options = ['Delete', 'Save', 'Cancel'];
    const destructiveButtonIndex = 0;
    const cancelButtonIndex = 2;

    showActionSheetWithOptions(
      {
        options,
        cancelButtonIndex,
        destructiveButtonIndex,
      },
      (buttonIndex) => {
        // Handle button press
        console.log('Selected option:', buttonIndex);
      }
    );
  };

  return (
    <View>
      <Button title="Open ActionSheet" onPress={onOpenActionSheet} />
    </View>
  );
};

export default App;

Other packages similar to @expo/react-native-action-sheet

Keywords

FAQs

Package last updated on 12 Jul 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc