-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): new composable - useHydration()
- Loading branch information
1 parent
0299efa
commit 05ec5b6
Showing
11 changed files
with
101 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: useHydration composable | ||
desc: What is useHydration() composable and how you can use it | ||
keys: useHydration | ||
badge: Quasar v2.15+ | ||
related: | ||
- /vue-components/no-ssr | ||
--- | ||
|
||
The useHydration composable is useful when you build for SSR (but can be used for non SSR builds as well). It is a lower level util of the [QNoSsr](/vue-components/no-ssr) component. | ||
|
||
## Syntax | ||
|
||
```js | ||
import { useHydration } from 'quasar' | ||
|
||
setup () { | ||
const { isHydrated } = useHydration() | ||
} | ||
``` | ||
|
||
```js | ||
function useHydration(): { | ||
isHydrated: Ref<boolean>; | ||
}; | ||
``` | ||
|
||
## Example | ||
|
||
```html | ||
<template> | ||
<div> | ||
<div v-if="isHydrated"> | ||
Gets rendered only after hydration. | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { useHydration } from 'quasar' | ||
export default { | ||
setup () { | ||
const { isHydrated } = useHydration() | ||
return { | ||
isHydrated | ||
} | ||
} | ||
} | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ref, onMounted } from 'vue' | ||
|
||
// using it to manage SSR rendering with best performance | ||
import { isRuntimeSsrPreHydration } from '../plugins/Platform.js' | ||
|
||
export default function () { | ||
const isHydrated = ref(!isRuntimeSsrPreHydration.value) | ||
|
||
if (isHydrated.value === false) { | ||
onMounted(() => { | ||
isHydrated.value = true | ||
}) | ||
} | ||
|
||
return { isHydrated } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters