Skip to content

Commit 6ca90de

Browse files
committed
fix(HomeChart): remove useAsyncData usage
1 parent 5a59fd8 commit 6ca90de

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

‎app/components/home/HomeChart.client.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ type DataRecord = {
1717
1818
const { width } = useElementSize(cardRef)
1919
20-
// We use `useAsyncData` here to have same random data on the client and server
21-
const { data } = await useAsyncData<DataRecord[]>(async () => {
20+
const data = ref<DataRecord[]>([])
21+
22+
watch([() => props.period, () => props.range], () => {
2223
const dates = ({
2324
daily: eachDayOfInterval,
2425
weekly: eachWeekOfInterval,
@@ -28,11 +29,8 @@ const { data } = await useAsyncData<DataRecord[]>(async () => {
2829
const min = 1000
2930
const max = 10000
3031
31-
return dates.map(date => ({ date, amount: Math.floor(Math.random() * (max - min + 1)) + min }))
32-
}, {
33-
watch: [() => props.period, () => props.range],
34-
default: () => []
35-
})
32+
data.value = dates.map(date => ({ date, amount: Math.floor(Math.random() * (max - min + 1)) + min }))
33+
}, { immediate: true })
3634
3735
const x = (_: DataRecord, i: number) => i
3836
const y = (d: DataRecord) => d.amount

0 commit comments

Comments
 (0)