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

Do not mutate the window state object #604

Merged
merged 1 commit into from
Apr 14, 2020
Merged

Do not mutate the window state object #604

merged 1 commit into from
Apr 14, 2020

Conversation

jameskerr
Copy link
Member

Fixes #600

This caused a strange bug where state.handlers was undefined. Then the app tried to do something with it, and it threw an error. I traced it back to this state mutation.

It's now locked in with a unit test

@jameskerr jameskerr requested review from mason-fish and a team April 13, 2020 22:10

store.dispatch(saveWindowState())

expect(store.getState()).toEqual(prevState)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the fix above, this would fail with the "errors" "notice" and "handlers" keys missing.

@jameskerr jameskerr requested a review from mattnibs April 14, 2020 18:59
Copy link
Contributor

@mattnibs mattnibs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little unschooled here but lgtm

@jameskerr jameskerr merged commit d95f931 into master Apr 14, 2020
@jameskerr jameskerr deleted the no-mutants branch April 14, 2020 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We mutate state in onBeforeUnload
2 participants