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-sheet-hook

v1.1.0

Published

This is a simple bottom sheet component for react native

Downloads

15

Readme

react-native-bottom-sheet-hook

Screen Recording 2024-05-16 at 4 21 16 PM

Features of this package :star_struck: :star_struck:

:sparkle: You can use useBottomSheet hook to control the bottom sheet from any component.

:sparkle: BottomSheetProvider higher order component helps to maintain clean code.

:sparkle: This package uses react-native-reanimated and react-native-gesture-handler for best performance.

:sparkle: All the animations are running on the main thread.

:sparkle: Customize the BottomSheet component the way you want. Pass props "globally" or override global props "locally".

Hey! Would you like to contribute to this package?! :raised_hands: :handshake:

Go ahead, fork the repo, and create many pull requests. :smile: :smile:

Installation Guide

install the package by running the below command

  npm install react-native-bottom-sheet-hook

or

  yarn add react-native-bottom-sheet-hook

Note: Since this package uses react-native-reanimated and react-native-gesture-handler, please follow the below steps

Wrap your root component with GestureHandlerRootView as below,

import { GestureHandlerRootView } from "react-native-gesture-handler";

return (
  <GestureHandlerRootView style={{ flex: 1 }}>  
    <NavigationContainer>
      <Stacks/>
    </NavigationContainer>
  </GestureHandlerRootView>
)

Add react-native-reanimated/plugin plugin to your babel.config.js

module.exports = {
    presets: [
      ... // don't add it here :)
    ],
    plugins: [
      ...
      // has to be listed last.
      'react-native-reanimated/plugin',
    ],
  };

How to use the package

Step 01

Wrap your screen component or the root component with BottomSheetProvider

import { BottomSheetProvider } from 'react-native-bottom-sheet-hook';

  <GestureHandlerRootView style={{ flex: 1 }}>
    <BottomSheetProvider>
      <NavigationContainer>
        <Stacks/>
      </NavigationContainer>
    </BottomSheetProvider>
  </GestureHandlerRootView>

Step 02

import the useBottomSheet and use show and hide functions. You need to pass the component to show in the bottom sheet as the argument to show function.

import React from "react";
import { View, StyleSheet, Button, Text } from "react-native";
import { useBottomSheet } from "react-native-bottom-sheet-hook";

export default function HomeScreen() {
  const { show, hide } = useBottomSheet();

  const renderBottomSheetComponent = () => {
    return (
      <View style={{ alignItems: "center" }}>
        <Text style={{ fontSize: 20, fontWeight: "bold" }}>Welcome to</Text>
        <Text style={{ fontSize: 18, fontWeight: "bold", marginTop: 20 }}>
          React Native Bottom Sheet Hook
        </Text>
        <Text style={{marginTop: 40, fontSize: 16}}>Use the "useBottomSheet" hook to control me</Text>
        <Button title="Close" color='red' onPress={hide} />
      </View>
    );
  };

  const handlePress = () => {
    show(renderBottomSheetComponent(), { height: 300 });
  };

  return (
    <View style={styles.container}>
      <Button title="Show bottom sheet" onPress={handlePress} />
    </View>
  );
}

Props

BottomSheetProvider Props

Prop name | type | required | description | default value --- | --- | --- | --- | --- hideHandle | boolean | N | Hide the handle of the bottom sheet | false hideBackground | boolean | N | Hide the background of the bottom sheet | false backgroundColor | string | N | Change the background color of the bottom sheet | '#303133' containerStyle | StyleProp | N | Change the container style of the bottom sheet | undefined height | number | N | Height of the bottom sheet | DEVICE_HEIGHT * 0.4

show method arguments

Argument name | type | required | description | default value --- | --- | --- | --- | --- component | ReactElement | Y | Component to render inside the BottomSheet config | Configurations | N | Set configurations for the BottomSheet component. Additionally, if you have set global configurations through BottomSheetProvider props, you can override them here | false

Configurations

Prop name | type | required | description | default value --- | --- | --- | --- | --- hideHandle | boolean | N | Hide the handle of the bottom sheet | false hideBackground | boolean | N | Hide the background of the bottom sheet | false backgroundColor | string | N | Change the background color of the bottom sheet | '#303133' containerStyle | StyleProp | N | Change the container style of the bottom sheet | undefined height | number | N | Height of the bottom sheet | DEVICE_HEIGHT * 0.4