npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-bottom-sheets

v1.0.3

Published

A tiny wrapper around @gorhom/bottom-sheet to make it easier to use in react-native projects.

Downloads

1

Readme

react-native-bottom-sheets

A lightweight, developer-friendly wrapper around @gorhom/bottom-sheet that simplifies the integration of multiple bottom sheets in React Native projects.

react native bottom sheet demo{width=300}

Features

  • No context providers needed: Use bottom sheets anywhere in your app without wrapping your code in context providers
  • Easy-to-use API for managing multiple bottom sheets across your app
  • Simplified state management for bottom sheets
  • Seamless integration with @gorhom/bottom-sheet
  • TypeScript support
  • Event-based communication for opening and closing bottom sheets

Installation

npm install react-native-bottom-sheets @gorhom/bottom-sheet

or

yarn add react-native-bottom-sheets @gorhom/bottom-sheet

Usage

  1. Add the BottomSheets component to your app's root component:
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { BottomSheets } from "react-native-bottom-sheets";
import YourBottomSheets from "./YourBottomSheets";

const bottomSheets = {
  FilterBottomSheet,
  WelcomeBottomSheet,
  AuthBottomSheet,
  // add your bottom sheets here
};

export default function App() {
  return (
    <GestureHandlerRootView>
      <YourApp />
      <BottomSheets sheets={bottomSheets} />
    </GestureHandlerRootView>
  );
}

Note: No need to wrap your app with any additional context providers!

  1. Create your bottom sheet components:
import { StyleSheet, View, Text } from "react-native";
import { BottomSheetProps, BottomSheet } from "react-native-bottom-sheets";

const AuthBottomSheet = ({ defaultProps, params }: BottomSheetProps) => {
  return (
    <BottomSheet snapPoints={["30%"]} {...defaultProps}>
      <View style={styles.container}>
        <Text>Auth Bottom Sheet</Text>
        <Text>{JSON.stringify(params, null, 2)}</Text>
      </View>
    </BottomSheet>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
  },
});

export default AuthBottomSheet;
  1. Use the useBottomSheets hook to manage bottom sheets from anywhere in your app:
import { useBottomSheets } from "react-native-bottom-sheets";

const YourComponent = () => {
  const { openBottomSheet, closeBottomSheet } = useBottomSheets();

  const handleOpenBottomSheet = () => {
    openBottomSheet("AuthBottomSheet", { someParam: "value" }, () => {
      console.log("Bottom sheet opened");
    });
  };

  return <Button title="Open Auth Sheet" onPress={handleOpenBottomSheet} />;
};

Why use react-native-bottom-sheets?

  1. No Context Providers: Unlike many state management solutions, this doesn't require you to wrap your app in context providers. This means less boilerplate and easier integration.

  2. Simplified API: Manage your bottom sheets with a clean, intuitive API.

  3. Global State Management: Control your bottom sheets from anywhere in your app without prop drilling or complex state management.

  4. TypeScript Support: Enjoy full TypeScript support for a better development experience.

  5. Flexible and Powerful: While simplifying the API, we maintain full access to @gorhom/bottom-sheet's props and features.

API

useBottomSheets Hook

  • openBottomSheet(name: string, params?: any, callback?: () => void): Opens a bottom sheet
  • closeBottomSheet(callback?: () => void): Closes the currently open bottom sheet

BottomSheet Component

Wrapper for the @gorhom/bottom-sheet component

  • ...all props from @gorhom/bottom-sheet

BottomSheets Component

  • sheets: Record<string, React.ComponentType<any>>: Object containing all your bottom sheet components

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.