summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/createReducer.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-core/src/createReducer.js')
-rw-r--r--packages/gitbook-core/src/createReducer.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/gitbook-core/src/createReducer.js b/packages/gitbook-core/src/createReducer.js
index 6860277..2ebecfb 100644
--- a/packages/gitbook-core/src/createReducer.js
+++ b/packages/gitbook-core/src/createReducer.js
@@ -9,8 +9,18 @@
function createReducer(name, reduce) {
return (state, action) => {
const value = state[name];
- state[name] = reduce(value, action);
- return state;
+ const newValue = reduce(value, action);
+
+ if (newValue === value) {
+ return state;
+ }
+
+ const newState = {
+ ...state,
+ [name]: newValue
+ };
+
+ return newState;
};
}