Skip to content

Commit

Permalink
fix(hooks): useSelector dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
acrazing committed Nov 14, 2020
1 parent 8061f45 commit 8c91110
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amos",
"version": "0.1.1",
"version": "0.1.2",
"description": "A decentralized state manager for react",
"keywords": [
"react",
Expand Down
3 changes: 2 additions & 1 deletion src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author acrazing <[email protected]>
*/

import { useContext, useDebugValue, useReducer, useRef } from 'react';
import { useContext, useDebugValue, useEffect, useReducer, useRef } from 'react';
import { __Context } from './context';
import { Selector } from './selector';
import { Dispatch, Selectable, Snapshot, Store } from './store';
Expand Down Expand Up @@ -200,6 +200,7 @@ export function useSelector<Rs extends Selectable[]>(...selectors: Rs): MapSelec
}),
};
}
useEffect(() => () => lastStore.current?.disposer(), []);
if (lastStore.current.error) {
const error = lastStore.current.error;
lastStore.current.error = void 0;
Expand Down

0 comments on commit 8c91110

Please sign in to comment.