Skip to content

Commit

Permalink
update mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-phan committed Sep 26, 2019
1 parent 9d673ca commit 6c2ad06
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "global-state-hook",
"version": "1.1.1",
"version": "1.1.2",
"description": "~200kb for exactly what you need to manage global state",
"source": "src/index.ts",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export interface IStateUpdater {
}

export function useSubscription(subscriber: ISubscription, pick: string[] = []): IStateUpdater {
const { state } = subscriber
let { state } = subscriber
const [, setUpdate] = React.useState()

const setState = React.useCallback((newState: State) => {
Object.assign(state, newState)
typeof newState === "object" ? Object.assign(state, newState) : (state = newState)
subscriber.listener.forEach(fn => fn(newState))
}, [])

Expand Down

0 comments on commit 6c2ad06

Please sign in to comment.