Prevent unhandled action from returning new state reference #1084
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request seeks to (a) resolve an issue where unhandled actions were inadvertently creating a new state reference and (b) introduce a new test to guard against such cases in the future. A Redux reducer should ideally never return a new reference if no changes have occurred, and especially if the action is never handled. It was found that
combineUndoableReducers
was testing the incorrect property when deciding whether to return the same state reference and therefore returned a new reference every time the reducer was invoked. This has been resolved here, and a test case added to protect against future regressions.Testing instructions:
There should be no behavioral changes in the editor.
Ensure tests pass:
cc @youknowriad , this was cause of issues described at #1077 (comment) (state did in-fact change, or at least the reference did).