Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unhandled action from returning new state reference #1084

Merged
merged 1 commit into from
Jul 24, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented Jun 8, 2017

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:

npm test

cc @youknowriad , this was cause of issues described at #1077 (comment) (state did in-fact change, or at least the reference did).

@aduth aduth added the Framework Issues related to broader framework topics, especially as it relates to javascript label Jun 8, 2017
@aduth aduth requested a review from youknowriad June 8, 2017 20:51
@aduth
Copy link
Member Author

aduth commented Jun 8, 2017

I added fe3cc68, which is not entirely related, but a small fix after observing that a new post incorrectly has undo history.

@aduth aduth force-pushed the fix/state-reference-change branch 2 times, most recently from d5457fe to d0158e0 Compare June 15, 2017 18:51
@aduth
Copy link
Member Author

aduth commented Jun 15, 2017

After #1063, it appears the changes from fe3cc68 are no longer necessary so have been dropped in rebase.

@aduth
Copy link
Member Author

aduth commented Jun 16, 2017

@youknowriad Appears redux-optimist returns a new object reference on every dispatch, causing the tests to fail. Reported at ForbesLindesay/redux-optimist#22 .

@aduth
Copy link
Member Author

aduth commented Jul 24, 2017

I'm going to rebase to drop the commit adding the base store change protection test, and move forward with the fix to undoableReducer because I'm encountering issues in another pull request.

@aduth
Copy link
Member Author

aduth commented Jul 24, 2017

Original commit for store change protection test (for future reference): d0158e0

@aduth aduth force-pushed the fix/state-reference-change branch from d0158e0 to 9345fc6 Compare July 24, 2017 18:59
@aduth aduth merged commit 941fe34 into master Jul 24, 2017
@aduth aduth deleted the fix/state-reference-change branch July 24, 2017 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant