# react-boom-store

> 47行代码实现的 react 状态管理库

Latest version **0.0.3** (published 2018-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-boom-store
pnpm add react-boom-store
yarn add react-boom-store
bun add react-boom-store
```

## 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.3 |
| Published | 2018-04-20 |
| First published | 2018-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 218.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | shiye515@gmail.com |
| Maintainers | shiye515 |

## Links

- npm: https://www.npmjs.com/package/react-boom-store
- Repository: https://github.com/shiye515/react-boom-store
- Issues: https://github.com/shiye515/react-boom-store/issues
- npm.io page: https://npm.io/package/react-boom-store

## Recent versions

- 0.0.3 (latest) — 2018-04-20
- 0.0.2 — 2018-04-20
- 0.0.1 — 2018-04-17

## README

# react-boom-store

47行代码实现的 react 状态管理库，没有 action 直接提交 reducer 来改变 store

## Installation

react-boom-store requires **React 16.3.2 or later.**

```
npm install --save react-boom-store
```

## Documentation

```javascript
import creatStore from 'react-boom-store'
const Store = creatStore(initState)
const { Provider, connect, dispatch } = Store
```
其中 Provider, connect 可以参考 react-redux 中对应的概念

dispatch 就相当于 React 中的 setState

## Example

### store.js
```javascript
import creatStore from '../src'

let initState = {
  example: {
    count: 5
  }
}
const { Provider, connect, dispatch } = creatStore(initState)

export {
  Provider,
  connect,
  dispatch
}
```
### index.js
```jsx
import React, { Component } from 'react'
import { render } from 'react-dom'
import { Provider, connect } from './store'

@connect(store => store.example)
class App extends Component {
  onClick = e => {
    const { dispatch } = this.props
    // 跟 setState 一样，注释中的用法也可以
    // dispatch({
    //   count: this.props.count + 1
    // })
    dispatch(function updateCount (prevState) {
      prevState.example.count = prevState.example.count + 1
      return prevState
    })
  }
  render () {
    const { count } = this.props
    return (
      <div onClick={this.onClick}>count: {count}</div>
    )
  }
}

render(
  (
    <Provider>
      <App />
    </Provider>
  ),
  document.getElementById('root')
)
```

## License

MIT

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