Closed arjun1194 closed 3 years ago
Implementing the interface ClassComponentHooks
solved the issue. Although Generally it could have been inside Vue itself. But implementing the interface also works.
export declare interface ClassComponentHooks {
data?(): object;
beforeCreate?(): void;
created?(): void;
beforeMount?(): void;
mounted?(): void;
beforeUnmount?(): void;
unmounted?(): void;
beforeUpdate?(): void;
updated?(): void;
activated?(): void;
deactivated?(): void;
render?(): VNode | void;
errorCaptured?(err: Error, vm: Vue, info: string): boolean | undefined;
serverPrefetch?(): Promise<unknown>;
}
export default class MainComponent extends Vue implements ClassComponentHooks
solved my issue, but i hope there was some good code documentation. Hope this helps someone else
This is a feature request. I think it would be good if a user can override lifecycle hooks instead of creating functions with the same name as lifecycle hook functions, like so
Doing it like this its easier to find from IDE what lifecycle hooks we have and this is the right object oriented way as other frameworks also do it like this ( e.g. android )