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-redux-confirm

v0.0.9

Published

Small library for managing re-usable confirm dialog state. This does not provide any kind of view component, it provides a HOC that lets you use your own modal.

Downloads

1

Readme

react-redux-confirm

Small library for managing re-usable confirm dialog state. This does not provide any kind of view component, it provides a HOC that lets you use your own modal.

Installation / Setup

  • First, install with npm i react-redux-confirm.
  • In your root reducer, import confirmReducers and add it to the confirmModal key. (Currently, this is not configurable.)
  • Create your modal component. react-redux-confirm will inject the following props into that modal component for you to use:
    • onConfirm: () => any - Call this when the user confirms the action (e.g. clicks 'Submit')
    • onCancel: () => any - Call this when the user cancels the action (e.g. clicks cancel or navigates away)
    • isOpen: boolean - Whether or not the modal is open.
    • message: ReactNode - The content to be displayed.
    • options?: any - Any further custom options you passed through to the action creator. Note that in the case of onConfirm and onCancel, you do not need to handle closing the modal. isOpen will be set to false automatically.
  • Import the HOC function withConfirm, and pass your modal view component to it: const ConfirmModal = withConfirm(MyModal).
    • If you'd like to connect this component, put the HOC inside the connect function: const ConfirmModal = connect(mapStateToProps)(withConfirm(MyModal))
  • Put the resulting component ConfirmModal wherever makes sense in your application.

Usage

Anywhere you'd like to make sure the user really means it, import ConfirmActions and dispatch ConfirmActions.confirm(options).
options is an object with the following shape:

{
  onConfirm?: () => any,
  onCancel?: () => any,
  message?: ReactNode,
  options?: any
}

If you'd like to hide the modal with an action, you may dispatch ConfirmActions.hide(). Similarly, if you'd like to unmount the modal view component, dispatch ConfirmActions.destroy(). You shouldn't need to use these in most cases.

Typescript

This package was written in Typescript and provides typings. ConfirmInjectedProps is an interface containing the props injected by the HOC for use by your view component.

Todo

  • Add an option to configure the delay with which the modal is automatically destroyed