# @cinimod/use-store

> Use Store hook and functions

Latest version **1.1.1** (published 2022-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cinimod/use-store
pnpm add @cinimod/use-store
yarn add @cinimod/use-store
bun add @cinimod/use-store
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-08-30 |
| First published | 2021-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marcony Neves |
| Maintainers | marcony |
| Keywords | store, context, hook, storage, state |

## Links

- npm: https://www.npmjs.com/package/@cinimod/use-store
- Repository: https://github.com/mkny/cinimod
- Homepage: https://github.com/mkny/cinimod#readme
- Issues: https://github.com/mkny/cinimod/issues
- npm.io page: https://npm.io/package/@cinimod/use-store

## Dependencies (5)

- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.map](https://npm.io/package/lodash.map.md) ^4.6.0
- [lodash.set](https://npm.io/package/lodash.set.md) ^4.3.2
- [lodash.reduce](https://npm.io/package/lodash.reduce.md) ^4.6.0
- [@cinimod/tsconfig](https://npm.io/package/@cinimod/tsconfig.md) ^1.0.1-alpha.0

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2022-08-30
- 1.1.0 — 2021-08-04

## README

# `@cinimod/use-store`

Provides a simple way to bind and hook 🎣 your application with React's Context API.

## Usage

- [Simple](#simple-usage)
- [With HOC](#using-with-hoc)
- [Setting a value](#setting-and-updating-value-to-the-context)

### Simple usage

You have your application running and need to put or retrieve something from Context.

```js
import { Provider, useStore } from "@cinimod/use-store";

const MyComponent = () => {
  const { get } = useStore();

  // Should return <p>myValue</p>
  return <p>{get("mykey")}</p>
}

const Container = () => {
  // Provider automatically injects context
  <Provider initialState={{
    mykey: "myValue"
  }}>
    <MyComponent />
  </Provider>
}
```

### Using with HOC

Using HOC to auto inject Context

```jsx
import { withStore, useStore } from "@cinimod/use-store";

const MyComponent = () => {
  const { get } = useStore();

  // Should return <p>myValue</p>
  return <p>{get("mykey")}</p>
}

export default withStore({
  initialState: {
    mykey: "myValue"
  }
})(MyComponent)
```

### Setting and Updating value to the context

```jsx
import { withStore, useStore } from "@cinimod/use-store";

const MyComponent = () => {
  const { set, get } = useStore();

  return (
    // Should update value, when click theButton
    <>
      <button onClick={() => set("mykey", "newValue")}>theButton</button>
      <p>{get("mykey")}</p>
    </>
  )
}

export default withStore({
  mykey: "myValue"
})(MyComponent)

```

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