Skip to content

I open and close

License

Notifications You must be signed in to change notification settings

aulisius/snitch

Repository files navigation

Snitch

I open and close

Redux connected React component to toggle visibility of your views.

The Problem

You have a view or a modal. You need to control its visibility. You maintain a value, lets say showModal either in your component state or in your redux store. It's cool. It works as intended.

After awhile, requirements come in. You now have more modals. Lots of them. showModal isn't going to cut it. In comes this library, taking care of that problem. Snitch listens to redux actions and maintains the showModal state internally and lets you focus on rendering the necessary views.

Installation

npm install prop-types react react-dom react-redux redux @faizaanceg/snitch --save

Basic code snippet

<Snitch
  opensOn={actionTypes.AUTH_SUCCESS}
  closesOn={actionTypes.AUTH_FAILURE}
  render={({ show }) => (show ? <Dashboard /> : <AccessDenied />)}
/>

Examples

You can check out the examples directory to see how you can use this library. Below is a list of similar examples but available interactively in CodeSandbox.

License

MIT

TODO

  • Add complete documentation
  • Add Typescript and Flow definitions
  • Add more non-trivial examples
  • Write tests (and achieve optimum coverage)

Contributing

PRs are welcome!