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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-hoc-modal

v0.2.10

Published

React component for easy create modals

Readme

React HOC Modal 🚀

npm version License: MIT TypeScript

A lightweight and flexible React modal component that makes creating and managing modals a breeze. Built with Higher-Order Components (HOC) pattern for maximum reusability and simplicity.

✨ Features

  • 🎯 Simple and intuitive API
  • 🔄 State management built-in
  • 🎨 Customizable themes
  • 📱 Responsive design with bottom sheet support
  • 🎭 Multiple modal support
  • 🔌 TypeScript support
  • 📱 Adaptive bottom sheet for mobile devices

Example Drag

📦 Installation

npm install react-hoc-modal

🚀 Quick Start

1. Set up the Modal Provider

First, wrap your application with the Modal Provider:

// index.jsx
import React from 'react';
import Modal from 'react-hoc-modal';

root.render(
  <React.StrictMode>
    <Modal.Provider>
      <App />
    </Modal.Provider>
  </React.StrictMode>
);

2. Create a Modal Component

Create your modal component using the withModal HOC:

// MyModal.jsx
import React from 'react';
import Modal from 'react-hoc-modal';

const MyModal = () => {
  const { state } = Modal.useModal();
  
  return (
    <div>
      <h2>{state?.title || 'Default Title'}</h2>
      <p>Hello, I am your modal component!</p>
    </div>
  );
};

export default Modal.withModal(MyModal, {
  title: 'My Awesome Modal',
  theme: 'light'
});

3. Use the Modal in Your App

// App.jsx
import React from 'react';
import MyModal from './MyModal';

const App = () => {
  return (
    <div>
      <button onClick={MyModal.show}>
        Open Modal
      </button>
      <MyModal />
    </div>
  );
};

🔧 API Reference

Modal Provider Props

| Prop | Type | Description | |------|------|-------------| | SPA | boolean | Enable SPA mode for better routing integration |

withModal Options

| Option | Type | Description | |--------|------|-------------| | title | string | Modal title | | theme | 'light' | 'dark' | Modal theme | | bottomSheet | boolean | Enable bottom sheet mode for mobile devices | | bottomSheetSnapPoints | string[] | Array of snap points for bottom sheet (e.g. ['50%', '70%']) | | bottomSheetMaxWidth | number | Screen width breakpoint for bottom sheet (default: 550px) |

Modal Methods

| Method | Description | |--------|-------------| | show() | Opens the modal | | hide() | Closes the modal | | setState(data) | Updates modal state |

useModal Hook

const { state } = Modal.useModal();

📝 Examples

Basic Usage

<button onClick={MyModal.show}>Show Modal</button>

State Management

// Update modal state
MyModal.setState({ title: 'New Title' });

// Access state in modal component
const MyModal = () => {
  const { state } = Modal.useModal();
  return <div>{state?.title}</div>;
};

Bottom Sheet Example

// BottomSheetModal.jsx
import React from 'react';
import Modal from 'react-hoc-modal';

const BottomSheetModal = () => {
  const { state } = Modal.useModal();
  
  return (
    <div>
      <h2>{state?.title}</h2>
      <p>This modal will appear as a bottom sheet on mobile devices!</p>
    </div>
  );
};

export default Modal.withModal(BottomSheetModal, {
  title: 'Bottom Sheet Example',
  bottomSheet: true,
  bottomSheetSnapPoints: ['50%', '70%'],
  // Optional: customize breakpoint
  bottomSheetMaxWidth: 550
});

The modal will automatically:

  • Display as a bottom sheet on screens smaller than 550px (or your custom size)
  • Show as a regular modal on larger screens
  • Support snap points for different heights
  • Provide smooth transitions between states

🤝 Contributing

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

📄 License

MIT © Sergey Serov