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

PreFetch not working with class components #8915

Closed
Evertvdw opened this issue Apr 16, 2021 · 0 comments
Closed

PreFetch not working with class components #8915

Evertvdw opened this issue Apr 16, 2021 · 0 comments
Labels

Comments

@Evertvdw
Copy link
Contributor

Describe the bug
When using class components the preFetch hook is not called. This is because the preFetch function is located not under c but under c.__c when using class components. See:
image

In the client-prefetch.js this line checks if the preFetch function exists: .filter(m => m.c && typeof m.c.preFetch === "function") which is of course never true when the preFetch function is not located there.

This also needs to be adjusted for SSR as the same preFetch checking logic is applied there.

To Reproduce
Steps to reproduce the behavior:
Create a preFetch hook in the @Options decorator when creating a class component. For example:

import { Vue, Options } from "vue-class-component";

@Options({
	preFetch() {
		return new Promise<void>(resolve => {
			console.log("preFetch hook called!");
			resolve();
		}) as any;
	},
})
export default class Test extends Vue {}

Expected behavior
PreFetch should work for class components, so I guess the logic of checking the preFetch function should be extended to also account for class components.

Can this get some priority? Because we cannot really upgrade if this is not working properly because we do depend on the preFetch hook quite a bit.

@Evertvdw Evertvdw added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Apr 16, 2021
IlCallo pushed a commit that referenced this issue Apr 19, 2021
* fix(preFetch): Call preFetch with class components #8915

preFetch is now called when used inside @options() in a class component.

* Add comments and fix prefetch for App.vue

* Simplify code for reviews

Co-authored-by: Evert van der Weit <evert@mett.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant