Skip to content

Commit

Permalink
use counter-based useForceUpdate (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Apr 7, 2019
1 parent db485e0 commit c9132a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Remove experimental useReduxStateMapped
### Changed
- useLayoutEffect and keep latest state after update (see #20)
- useForceUpdate uses counter instead of boolean (see #20)

## [1.8.0] - 2019-04-02
### Changed
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var warningObject = {
var ReduxStoreContext = (0, _react.createContext)(warningObject); // helper hooks

var forcedReducer = function forcedReducer(state) {
return !state;
return state + 1;
};

var useForceUpdate = function useForceUpdate() {
return (0, _react.useReducer)(forcedReducer, false)[1];
return (0, _react.useReducer)(forcedReducer, 0)[1];
};

var useProxyfied = function useProxyfied(state) {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const ReduxStoreContext = createContext(warningObject);

// helper hooks

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

const useProxyfied = (state) => {
// cache
Expand Down

0 comments on commit c9132a9

Please sign in to comment.