Skip to content

Commit 85a183c

Browse files
fix(devtools): register devtools on root only (#214)
1 parent 16e73d0 commit 85a183c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/vuejs/__tests__/vueQueryPlugin.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface TestApp extends App {
1313
_unmount: Function;
1414
_mixin: ComponentOptions;
1515
_provided: Record<string, any>;
16+
$root: TestApp;
1617
}
1718

1819
const testIf = (condition: boolean) => (condition ? test : test.skip);
@@ -56,6 +57,7 @@ describe("VueQueryPlugin", () => {
5657
const appMock = getAppMock();
5758
VueQueryPlugin.install?.(appMock);
5859

60+
appMock.$root = appMock;
5961
appMock._mixin.beforeCreate?.call(appMock);
6062
process.env.NODE_ENV = envCopy;
6163

src/vuejs/vueQueryPlugin.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export const VueQueryPlugin = {
7777

7878
/* istanbul ignore next */
7979
if (isVue2) {
80-
// Workaround for Vue2 calling mixin multiple times
81-
let devtoolsRegistered = false;
8280
app.mixin({
8381
beforeCreate() {
8482
// HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30
@@ -92,10 +90,9 @@ export const VueQueryPlugin = {
9290

9391
this._provided[clientKey] = client;
9492

95-
if (!devtoolsRegistered) {
96-
if (process.env.NODE_ENV === "development") {
93+
if (process.env.NODE_ENV === "development") {
94+
if (this === this.$root) {
9795
setupDevtools(this, client);
98-
devtoolsRegistered = true;
9996
}
10097
}
10198
},

0 commit comments

Comments
 (0)