# flashbang

> small set of awesome react utilities

Latest version **0.0.7** (published 2018-01-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install flashbang
pnpm add flashbang
yarn add flashbang
bun add flashbang
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2018-01-11 |
| First published | 2016-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zach Silveira |
| Maintainers | thekenwheeler, zackify |
| Keywords | reactjs, react, toggle, url, state |

## Links

- npm: https://www.npmjs.com/package/flashbang
- Repository: https://github.com/kimmelsg/flashbang
- Homepage: https://github.com/kimmelsg/flashbang#readme
- Issues: https://github.com/kimmelsg/flashbang/issues
- npm.io page: https://npm.io/package/flashbang

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2018-01-11
- 0.0.6 — 2017-11-28
- 0.0.5 — 2017-09-22
- 0.0.4 — 2017-09-21
- 0.0.3 — 2017-09-20
- 0.0.2 — 2017-09-19
- 0.0.1 — 2016-03-02

## README

# flashbang

[![CircleCI](https://circleci.com/gh/kimmelsg/flashbang.svg?style=svg)](https://circleci.com/gh/kimmelsg/flashbang)
[![Coverage Status](https://coveralls.io/repos/github/kimmelsg/tracker/badge.svg?branch=master)](https://coveralls.io/github/kimmelsg/tracker?branch=master)

- [QueryState](#query-state)
- [Toggle](#toggle)
- [Paginate](#paginate)
- [Async Action](#async-action)

## Install

```js
npm install flashbang
```

## Query State

Stores state in the url. Useful for search pages. Must be rendered inside react-router v4.

- [source](/src/query-state.js)
- [tests](/tests/query-state.js)
- [example](/example/src/example/query-state.js)

```js
import { QueryState } from 'flashbang'

const example = ({ state, setState }) => (
  <div>
    <input
      value={state.test}
      onChange={e => setState({ test: e.target.value })}
    />
  </div>
);

export default QueryState(example);
```


## Toggle

Toggle the display of data with three simple props!

- [source](/src/toggle.js)
- [tests](/tests/toggle.js)
- [example](/example/src/example/toggle.js)

```js
import { Toggle } from 'flashbang'

<Toggle>
  <div toggle>Swap</div>

  <div on>This is shown when toggled</div>
  <div off>This is shown when not toggled</div>
</Toggle>
```


## Paginate

Display 5 page numbers in either direction with next and previous buttons

- [source](/src/paginate)
- [tests](/tests/paginate.js)
- [example](/example/src/example/paginate.js)

Import the default css, or pass your own class names and use your own css!

```js
import { Paginate } from 'flashbang';
import 'flashbang/dist/paginate/style.css';

export default () => (
  <Paginate
    page={5}
    pages={25}
    createURL={page => `?page=${page}`}
  />
);
```


## Async Action

Changes text depending on promise status. Blocks onClick if a promise is in the middle of resolving, or finished.

- [source](/src/async-action.js)
- [tests](/tests/async-action.js)
- [example](/example/src/example/async-action.js)

```js
import { AsyncAction } from 'flashbang'

<AsyncAction
  onClick={() => new Promise(resolve => setTimeout(resolve, 100))}
  before={<div>Create</div>}
  during={<div>Creating...</div>}
  after={<span>Created!</span>}
/>
```

## Examples

The `examples` directory is a `create-react-app` module, so you can `npm start` or `npm run build` to see the demos live.

---
_Source: https://npm.io/package/flashbang · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
