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

[Optimization] The useXXX method can be directly called in the vue component, and it can be automatically uninstalled #30135

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update keyboard.ts
vue自动注销
mchao123 authored Jan 15, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7ffd6ceec0d8454f1f23228b8ad88ca339f2caf9
8 changes: 7 additions & 1 deletion packages/vue/src/hooks/keyboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Ref } from "vue";
import { ref } from "vue";
import { ref, onBeforeUnmount, getCurrentInstance } from "vue";

export interface UseKeyboardResult {
isOpen: Ref<boolean>;
@@ -33,6 +33,12 @@ export const useKeyboard = (): UseKeyboardResult => {
window.addEventListener("ionKeyboardDidHide", hideCallback);
}

if (getCurrentInstance()){
onBeforeUnmount(() => {
unregister()
});
}

return {
isOpen,
keyboardHeight,