Skip to content

Commit 1bc0434

Browse files
committed
remove use of reactivity transform
1 parent 5cfc2a4 commit 1bc0434

32 files changed

+126
-135
lines changed

Diff for: .vitepress/config.ts

-4
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,5 @@ export default defineConfigWithTheme<ThemeConfig>({
687687
json: {
688688
stringify: true
689689
}
690-
},
691-
692-
vue: {
693-
reactivityTransform: true
694690
}
695691
})

Diff for: .vitepress/theme/components/Banner.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
* 2. uncomment and update BANNER_ID in ../../inlined-scripts/restorePreferences.ts
66
* 3. update --vt-banner-height if necessary
77
*/
8+
import { ref } from 'vue'
9+
10+
const open = ref(true)
811
9-
let open = $ref(true)
1012
/**
1113
* Call this if the banner is dismissible
1214
*/
1315
function dismiss() {
14-
open = false
16+
open.value = false
1517
document.documentElement.classList.add('banner-dismissed')
1618
localStorage.setItem(`vue-docs-banner-${__VUE_BANNER_ID__}`, 'true')
1719
}

Diff for: .vitepress/theme/components/PreferenceSwitch.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { VTSwitch, VTIconChevronDown } from '@vue/theme'
33
import { useRoute } from 'vitepress'
4-
import { inject, Ref } from 'vue'
4+
import { ref, computed, inject, Ref } from 'vue'
55
import {
66
preferCompositionKey,
77
preferComposition,
@@ -10,15 +10,15 @@ import {
1010
} from './preferences'
1111
1212
const route = useRoute()
13-
const show = $computed(() =>
13+
const show = computed(() =>
1414
/^\/(guide|tutorial|examples|style-guide)\//.test(route.path)
1515
)
16-
const showSFC = $computed(() => !/^\/guide|style-guide/.test(route.path))
16+
const showSFC = computed(() => !/^\/guide|style-guide/.test(route.path))
1717
18-
let isOpen = $ref(true)
18+
let isOpen = ref(true)
1919
2020
const toggleOpen = () => {
21-
isOpen = !isOpen
21+
isOpen.value = !isOpen.value
2222
}
2323
2424
const removeOutline = (e: Event) => {

Diff for: .vitepress/theme/components/SponsorsGroup.vue

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
<script setup lang="ts">
2-
import { onMounted, onUnmounted } from 'vue'
2+
import { ref, onMounted, onUnmounted } from 'vue'
33
import { SponsorData, data, base, load } from './sponsors'
44
55
type Placement = 'aside' | 'page' | 'landing'
66
7-
const { tier, placement = 'aside' } = defineProps<{
8-
tier: keyof SponsorData
9-
placement?: Placement
10-
}>()
7+
const props = withDefaults(
8+
defineProps<{
9+
tier: keyof SponsorData
10+
placement?: Placement
11+
}>(),
12+
{
13+
placement: 'aside'
14+
}
15+
)
1116
12-
let container = $ref<HTMLElement>()
13-
let visible = $ref(false)
17+
const container = ref<HTMLElement>()
18+
const visible = ref(false)
1419
1520
onMounted(async () => {
1621
// only render when entering view
1722
const observer = new IntersectionObserver(
1823
(entries) => {
1924
if (entries[0].isIntersecting) {
20-
visible = true
25+
visible.value = true
2126
observer.disconnect()
2227
}
2328
},
2429
{ rootMargin: '0px 0px 300px 0px' }
2530
)
26-
observer.observe(container!)
31+
observer.observe(container.value!)
2732
onUnmounted(() => observer.disconnect())
2833
2934
// load data
@@ -38,7 +43,7 @@ const eventMap: Record<Placement, string> = {
3843
}
3944
4045
function track(interest?: boolean) {
41-
fathom.trackGoal(interest ? `Y2BVYNT2` : eventMap[placement], 0)
46+
fathom.trackGoal(interest ? `Y2BVYNT2` : eventMap[props.placement], 0)
4247
}
4348
</script>
4449

Diff for: .vitepress/theme/components/VueJobs.vue

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<script lang="ts">
2+
import { ref } from 'vue'
3+
24
// shared data across instances so we load only once
35
const base = 'https://app.vuejobs.com/feed/vuejs/docs?format=json'
46
5-
let items = $ref<Jobs[]>([])
7+
const items = ref<Jobs[]>([])
68
79
type Jobs = {
810
organization: Organization
@@ -21,19 +23,19 @@ type Organization = {
2123
<script setup lang="ts">
2224
import { onMounted, computed } from 'vue'
2325
24-
let vuejobs = $ref<HTMLElement>()
25-
2626
const openings = computed(() =>
27-
items.sort(() => 0.5 - Math.random()).slice(0, 2)
27+
items.value.sort(() => 0.5 - Math.random()).slice(0, 2)
2828
)
2929
3030
onMounted(async () => {
31-
if (!items.length) items = (await (await fetch(`${base}`)).json()).data
31+
if (!items.value.length) {
32+
items.value = (await (await fetch(`${base}`)).json()).data
33+
}
3234
})
3335
</script>
3436

3537
<template>
36-
<div class="vuejobs-wrapper" ref="vuejobs">
38+
<div class="vuejobs-wrapper">
3739
<div class="vj-container">
3840
<a
3941
class="vj-item"
@@ -45,15 +47,17 @@ onMounted(async () => {
4547
<div class="vj-company-logo">
4648
<img
4749
:src="job.organization.avatar"
48-
:alt="`Logo for ${job.organization.name}`" />
50+
:alt="`Logo for ${job.organization.name}`"
51+
/>
4952
</div>
5053
<div
5154
style="
5255
overflow: hidden;
5356
display: flex;
5457
flex-direction: column;
5558
justify-content: center;
56-
">
59+
"
60+
>
5761
<div class="vj-job-title">{{ job.title }}</div>
5862
<div class="vj-job-info">
5963
{{ job.organization.name }} <span>· </span>

Diff for: .vitepress/theme/components/VueMasteryModal.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
2-
import { watch } from 'vue'
2+
import { ref, watch } from 'vue'
33
44
const VIDEO_SOURCE = 'https://player.vimeo.com/video/647441538?autoplay=1'
5-
let showWhyVue: boolean = $ref(false)
5+
const showWhyVue = ref(false)
66
77
watch(
88
() => showWhyVue,

Diff for: env.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference types="vitepress/client" />
2-
/// <reference types="vue/macros-global" />
32

43
declare module '@vue/theme/config' {
54
import { UserConfig } from 'vitepress'

Diff for: src/about/releases.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ outline: deep
33
---
44

55
<script setup>
6-
import { onMounted } from 'vue'
6+
import { ref, onMounted } from 'vue'
77

8-
let version = $ref()
8+
const version = ref()
99

1010
onMounted(async () => {
1111
const res = await fetch('https://api.github.com/repos/vuejs/core/releases?per_page=1')
12-
version = (await res.json())[0].name
12+
version.value = (await res.json())[0].name
1313
})
1414
</script>
1515

Diff for: src/guide/built-ins/keep-alive-demos/CompA.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
2-
let count = $ref(0)
2+
import { ref } from 'vue'
3+
const count = ref(0)
34
</script>
45

56
<template>

Diff for: src/guide/built-ins/keep-alive-demos/CompB.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
2-
let msg = $ref('')
2+
import { ref } from 'vue'
3+
const msg = ref('')
34
</script>
45

56
<template>

Diff for: src/guide/built-ins/keep-alive-demos/SwitchComponent.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script setup>
2+
import { shallowRef } from 'vue'
23
import CompA from './CompA.vue'
34
import CompB from './CompB.vue'
45
5-
let current = $shallowRef(CompA)
6+
const current = shallowRef(CompA)
67
7-
const { useKeepAlive } = defineProps({ useKeepAlive: Boolean })
8+
defineProps({ useKeepAlive: Boolean })
89
</script>
910

1011
<template>

Diff for: src/guide/built-ins/teleport.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ The `to` target of `<Teleport>` expects a CSS selector string or an actual DOM n
116116
You can click the button below and inspect the `<body>` tag via your browser's devtools:
117117

118118
<script setup>
119-
let open = $ref(false)
119+
import { ref } from 'vue'
120+
const open = ref(false)
120121
</script>
121122

122123
<div class="demo">

Diff for: src/guide/built-ins/transition-demos/Basic.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
2-
let show = $ref(true)
2+
import { ref } from 'vue'
3+
const show = ref(true)
34
</script>
45

56
<template>

Diff for: src/guide/built-ins/transition-demos/BetweenComponents.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup>
2-
import { h } from 'vue'
2+
import { h, ref } from 'vue'
33
44
const CompA = () => h('div', 'Component A')
55
const CompB = () => h('div', 'Component B')
66
7-
let activeComponent = $ref(CompA)
7+
const activeComponent = ref(CompA)
88
</script>
99

1010
<template>

Diff for: src/guide/built-ins/transition-demos/BetweenElements.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup>
2-
const { mode } = defineProps(['mode'])
2+
import { ref } from 'vue'
33
4-
let docState = $ref('saved')
4+
defineProps(['mode'])
5+
6+
const docState = ref('saved')
57
</script>
68

79
<template>

Diff for: src/guide/built-ins/transition-demos/CssAnimation.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
2-
let show = $ref(true)
2+
import { ref } from 'vue'
3+
const show = ref(true)
34
</script>
45

56
<template>

Diff for: src/guide/built-ins/transition-demos/JsHooks.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup>
2+
import { ref } from 'vue'
23
import gsap from 'gsap'
34
4-
let show = $ref(true)
5+
const show = ref(true)
56
67
function onBeforeEnter(el) {
78
gsap.set(el, {

Diff for: src/guide/built-ins/transition-demos/ListMove.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<script setup>
2-
let items = $ref([1, 2, 3, 4, 5])
3-
let nextNum = items.length + 1
2+
import { ref } from 'vue'
3+
const items = ref([1, 2, 3, 4, 5])
4+
let nextNum = items.value.length + 1
45
56
function add() {
6-
items.splice(randomIndex(), 0, nextNum++)
7+
items.value.splice(randomIndex(), 0, nextNum++)
78
}
89
910
function remove() {
10-
items.splice(randomIndex(), 1)
11+
items.value.splice(randomIndex(), 1)
1112
}
1213
1314
function randomIndex() {
14-
return Math.floor(Math.random() * items.length)
15+
return Math.floor(Math.random() * items.value.length)
1516
}
1617
1718
function shuffle(array) {

Diff for: src/guide/built-ins/transition-demos/ListStagger.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup>
2+
import { ref, computed } from 'vue'
23
import gsap from 'gsap'
34
45
const list = [
@@ -9,9 +10,9 @@ const list = [
910
{ msg: 'Kung Fury' }
1011
]
1112
12-
let query = $ref('')
13+
const query = ref('')
1314
14-
const computedList = $computed(() => {
15+
const computedList = computed(() => {
1516
return list.filter((item) => item.msg.toLowerCase().includes(query))
1617
})
1718

Diff for: src/guide/built-ins/transition-demos/NestedTransitions.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
2-
let show = $ref(true)
2+
import { ref } from 'vue'
3+
const show = ref(true)
34
</script>
45

56
<template>

Diff for: src/guide/built-ins/transition-demos/SlideFade.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
2-
let show = $ref(true)
2+
import { ref } from 'vue'
3+
const show = ref(true)
34
</script>
45

56
<template>

Diff for: src/guide/essentials/reactivity-fundamentals.md

-25
Original file line numberDiff line numberDiff line change
@@ -573,28 +573,3 @@ export default {
573573
```
574574

575575
</div>
576-
577-
<div class="composition-api">
578-
579-
## Reactivity Transform <sup class="vt-badge experimental" /> \*\* {#reactivity-transform}
580-
581-
Having to use `.value` with refs is a drawback imposed by the language constraints of JavaScript. However, with compile-time transforms we can improve the ergonomics by automatically appending `.value` in appropriate locations. Vue provides a compile-time transform that allows us to write the earlier "counter" example like this:
582-
583-
```vue
584-
<script setup>
585-
let count = $ref(0)
586-
587-
function increment() {
588-
// no need for .value
589-
count++
590-
}
591-
</script>
592-
593-
<template>
594-
<button @click="increment">{{ count }}</button>
595-
</template>
596-
```
597-
598-
You can learn more about [Reactivity Transform](/guide/extras/reactivity-transform.html) in its dedicated section. Do note that it is currently still experimental and may change before being finalized.
599-
600-
</div>

Diff for: src/guide/extras/demos/Colors.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<script setup>
2-
let x = $ref(0)
2+
import { ref } from 'vue'
3+
4+
const x = ref(0)
5+
36
function onMousemove(e) {
4-
x = e.clientX
7+
x.value = e.clientX
58
}
69
</script>
710

0 commit comments

Comments
 (0)