diff --git a/CHANGELOG.md b/CHANGELOG.md index 27edcd8..7187658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/dist/index.js b/dist/index.js index bfe52db..bc92b32 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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) { diff --git a/src/index.js b/src/index.js index af8a5dd..4e05ef8 100644 --- a/src/index.js +++ b/src/index.js @@ -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