Skip to content

Commit 4d0f0ac

Browse files
committed
perf: use shallowRef where possible
1 parent 6d96f7e commit 4d0f0ac

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

app/components/CollapsibleSection.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref, computed } from 'vue'
2+
import { shallowRef, computed } from 'vue'
33
44
interface Props {
55
title: string
@@ -19,7 +19,7 @@ const buttonId = `${props.id}-collapsible-button`
1919
const contentId = `${props.id}-collapsible-content`
2020
const headingId = `${props.id}-heading`
2121
22-
const isOpen = ref(true)
22+
const isOpen = shallowRef(true)
2323
2424
onPrehydrate(() => {
2525
const settings = JSON.parse(localStorage.getItem('npmx-settings') || '{}')

app/components/compare/PackageSelector.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const props = defineProps<{
99
const maxPackages = computed(() => props.max ?? 4)
1010
1111
// Input state
12-
const inputValue = ref('')
13-
const isInputFocused = ref(false)
12+
const inputValue = shallowRef('')
13+
const isInputFocused = shallowRef(false)
1414
1515
// Use the shared npm search composable
1616
const { data: searchData, status } = useNpmSearch(inputValue, { size: 15 })

app/composables/usePackageComparison.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
3939
// Derived array in current package order
4040
const packagesData = computed(() => packages.value.map(name => cache.value.get(name) ?? null))
4141

42-
const status = ref<'idle' | 'pending' | 'success' | 'error'>('idle')
43-
const error = ref<Error | null>(null)
42+
const status = shallowRef<'idle' | 'pending' | 'success' | 'error'>('idle')
43+
const error = shallowRef<Error | null>(null)
4444

4545
// Track which packages are currently being fetched
4646
const loadingPackages = shallowRef(new Set<string>())
4747

4848
// Track install size loading separately (it's slower)
49-
const installSizeLoading = ref(false)
49+
const installSizeLoading = shallowRef(false)
5050

5151
// Fetch function - only fetches packages not already in cache
5252
async function fetchPackages(names: string[]) {

0 commit comments

Comments
 (0)