Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hookstore

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hookstore - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

10

package.json
{
"name": "react-hookstore",
"version": "1.1.5",
"version": "1.1.6",
"description": "A state management library for react using the bleeding edge hooks feature",

@@ -48,4 +48,4 @@ "main": "dist/react-hookstore.js",

"jest": "^23.6.0",
"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"regenerator-runtime": "^0.13.1",

@@ -58,4 +58,4 @@ "webpack": "^4.23.1",

"peerDependencies": {
"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0"
"react": "^16.8.0",
"react-dom": "^16.8.0"
},

@@ -62,0 +62,0 @@ "files": [

@@ -19,3 +19,3 @@ # React Hook Store

- [StoreInterface](#api_storeInterface)
- [usStore](#api_useStore)
- [useStore](#api_useStore)
- [Migrating from v1.0 to v1.1](#migration)

@@ -25,6 +25,5 @@

> ⚠️ Warning: hooks are not part of a stable React release yet, so use this library only for experiments
## <a name="installation">Installation</a>
You can install the lib through NPM or grab the files in the `dist` folder of this repository.
`npm install --save react-hookstore`

@@ -60,3 +59,3 @@

// you can name the state whatever you want
const [ timesClicked ] = useStore();
const [ timesClicked ] = useStore('clickStore');
return (

@@ -109,3 +108,2 @@ <div>

// this one is more complex, it has a name and a reducer function
const todoListStore = createStore(

@@ -182,3 +180,3 @@ 'todoList',

The store's initial state. it can be any data type. defaults to an empty object. Optional
#### `reducer:Function = null`
#### `reducer:Function`
You can specify a reducer function to take care of state changes. the reducer functions receives two arguments, the previous state and the action that triggered the state update. the function must return a new state, if not, the new state will be `null`. Optional

@@ -189,3 +187,3 @@

### Arguments
#### `name:String = 'store'`
#### `name:String
The name of the store.

@@ -201,10 +199,10 @@

A method that returns the store's current state
#### `setState:Function(*)`
#### `setState:Function(state:*)`
Sets the state of the store. works if the store does not use a reducer state handler. Otherwise, use `dispatch`
#### `dispatch:Function(*)`
#### `dispatch:Function(action:*)`
Dispatchs whatever is passed into this function to the store. works if the store uses a reducer state handler. Otherwise, use `setState`
## React API
### <a name="api_useStore">`useStore(identifier:String|StoreInterface)`</a>
A function that returns a pair with the current state and the handler method for the specified store.
### <a name="api_useStore">`useStore(identifier:String|StoreInterface):Array[state, setState|dispatch]`</a>
A function that returns a pair with the current state and a function to trigger state updates for the specified store.
### Arguments

@@ -218,3 +216,3 @@ #### Identifier:String|StoreInterface

```javascript
// v0.1
// v1.0
createStore({state: 0});

@@ -228,5 +226,5 @@ createStore({

})
// v0.2
// v1.1
createStore('myStore', 0);
createStore('store', 0, (state, value) => state + action);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc