Skip to content

Commit

Permalink
fix: review composable
Browse files Browse the repository at this point in the history
  • Loading branch information
mnenie committed Dec 16, 2024
1 parent 267a55a commit d98105b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import type { Review } from '../types'
import { onMounted, ref } from 'vue'
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'

export default function useTextChanging(reviews: Review[]) {
// so, maybe Ill do with live data
const currentIndex = ref(0)
const route = useRoute()

const changeReviewText = () => {
currentIndex.value = Math.floor(Math.random() * reviews.length)
}
onMounted(() => {
watch(() => route.path, () => {
changeReviewText()
})
}, { immediate: true })

return {
currentIndex,
Expand Down

0 comments on commit d98105b

Please sign in to comment.