react-use
Advanced tools
Comparing version 5.4.1 to 5.5.0
@@ -0,1 +1,14 @@ | ||
# [5.5.0](https://github.com/streamich/react-use/compare/v5.4.1...v5.5.0) (2019-02-23) | ||
### Bug Fixes | ||
* add type definition for useList() remove() method ([ea2dc43](https://github.com/streamich/react-use/commit/ea2dc43)) | ||
* useSetState bug ([83611a1](https://github.com/streamich/react-use/commit/83611a1)) | ||
### Features | ||
* Add remove method for useList ([5a295d9](https://github.com/streamich/react-use/commit/5a295d9)) | ||
## [5.4.1](https://github.com/streamich/react-use/compare/v5.4.0...v5.4.1) (2019-02-19) | ||
@@ -2,0 +15,0 @@ |
export interface Actions<T> { | ||
set: (list: T[]) => void; | ||
updateAt: (index: number, item: T) => void; | ||
remove: (index: number) => void; | ||
push: (item: T) => void; | ||
@@ -5,0 +6,0 @@ filter: (fn: (value: T) => boolean) => void; |
@@ -13,2 +13,6 @@ "use strict"; | ||
]), | ||
remove: (index) => set([ | ||
...list.slice(0, index), | ||
...list.slice(index + 1) | ||
]), | ||
push: (entry) => set([...list, entry]), | ||
@@ -15,0 +19,0 @@ filter: (fn) => set(list.filter(fn)), |
@@ -7,6 +7,3 @@ "use strict"; | ||
const setState = patch => { | ||
if (patch instanceof Function) | ||
set(prevState => Object.assign({}, prevState, patch(prevState))); | ||
else | ||
set(Object.assign({}, state, patch)); | ||
set(prevState => Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch)); | ||
}; | ||
@@ -13,0 +10,0 @@ return [state, setState]; |
{ | ||
"name": "react-use", | ||
"version": "5.4.1", | ||
"version": "5.5.0", | ||
"description": "Collection of React Hooks", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
89236
1911