Skip to content

Commit c9132a9

Browse files
committed
use counter-based useForceUpdate (#20)
1 parent db485e0 commit c9132a9

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Remove experimental useReduxStateMapped
66
### Changed
77
- useLayoutEffect and keep latest state after update (see #20)
8+
- useForceUpdate uses counter instead of boolean (see #20)
89

910
## [1.8.0] - 2019-04-02
1011
### Changed

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ var warningObject = {
2929
var ReduxStoreContext = (0, _react.createContext)(warningObject); // helper hooks
3030

3131
var forcedReducer = function forcedReducer(state) {
32-
return !state;
32+
return state + 1;
3333
};
3434

3535
var useForceUpdate = function useForceUpdate() {
36-
return (0, _react.useReducer)(forcedReducer, false)[1];
36+
return (0, _react.useReducer)(forcedReducer, 0)[1];
3737
};
3838

3939
var useProxyfied = function useProxyfied(state) {

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const ReduxStoreContext = createContext(warningObject);
3131

3232
// helper hooks
3333

34-
const forcedReducer = state => !state;
35-
const useForceUpdate = () => useReducer(forcedReducer, false)[1];
34+
const forcedReducer = state => state + 1;
35+
const useForceUpdate = () => useReducer(forcedReducer, 0)[1];
3636

3737
const useProxyfied = (state) => {
3838
// cache

0 commit comments

Comments
 (0)