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

State is fully observed and deeply cloned instead of statePaths only #106

Open
tspoke opened this issue Jan 12, 2023 · 1 comment
Open

Comments

@tspoke
Copy link

tspoke commented Jan 12, 2023

Hi,

The PR #64 introduced a bug. The full state is observed and is deeply cloned before the filtering of the statesPaths the next line.
This lead to a full state copy instead of only the portions we need to sync.

You should only clone the wanted portion of the state :

    if (statesPaths.length === 0) return { ...newState };
    
    statesPaths.forEach((statePath) => {
      const newValue = cloneObj(pick(statePath, newState)); // clone only the wanted path
      ...

The faulty line is here : https://github.com/abernh/vuex-multi-tab-state/blob/3d0bc186db0741309f1e1a42fb26dad964f5f5b5/src/index.ts#L48

@andreww2012
Copy link

This deep cloning algorithm is also causing issues for objects with Dates. That said, I'm not entirely sure whether it is a good practice/officially (not) recommended to store Dates in Vuex in the first place, but that caused crashes in production because Dates had been destroyed after the cloning.

Though I'm very grateful for that library, it was a real savior for me.

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

No branches or pull requests

2 participants