Skip to content

Commit

Permalink
Merge pull request rancher#11097 from rak-phillip/chore/non-reactive-…
Browse files Browse the repository at this point in the history
…data

Use `markRaw()` to signal non reactive data in store
  • Loading branch information
rak-phillip authored May 29, 2024
2 parents 43ef5fc + b722e40 commit 67dd70e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions shell/plugins/dashboard-store/mutations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue from 'vue';
import Vue, { markRaw } from 'vue';
import { addObject, addObjects, clear, removeObject } from '@shell/utils/array';
import { SCHEMA, COUNT } from '@shell/config/types';
import { normalizeType, keyFieldFor } from '@shell/plugins/dashboard-store/normalize';
Expand Down Expand Up @@ -34,10 +34,10 @@ function registerType(state, type) {
* Used to cancel incremental loads if the page changes during load
*/
loadCounter: 0,
};

// Not enumerable so they don't get sent back to the client for SSR
Object.defineProperty(cache, 'map', { value: new Map() });
// Not enumerable so they don't get sent back to the client for SSR
map: markRaw(new Map()),
};

Vue.set(state.types, type, cache);
}
Expand Down
13 changes: 7 additions & 6 deletions shell/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { addParam } from '@shell/utils/url';
import semver from 'semver';
import { STORE, BLANK_CLUSTER } from '@shell/store/store-types';
import { isDevBuild } from '@shell/utils/version';
import { markRaw } from 'vue';

// Disables strict mode for all store instances to prevent warning about changing state outside of mutations
// because it's more efficient to do that sometimes.
Expand Down Expand Up @@ -247,9 +248,9 @@ export const state = () => {
isRancherInHarvester: false,
targetRoute: null,
rootProduct: undefined,
$router: undefined,
$route: undefined,
$plugin: undefined,
$router: markRaw(undefined),
$route: markRaw(undefined),
$plugin: markRaw(undefined),
};
};

Expand Down Expand Up @@ -728,15 +729,15 @@ export const mutations = {
},

setRouter(state, router) {
state.$router = router;
state.$router = markRaw(router);
},

setRoute(state, route) {
state.$route = route;
state.$route = markRaw(route);
},

setPlugin(state, pluginDefinition) {
state.$plugin = pluginDefinition;
state.$plugin = markRaw(pluginDefinition);
}
};

Expand Down

0 comments on commit 67dd70e

Please sign in to comment.