Skip to content

Commit c74adfa

Browse files
committed
Refactoring perPage to a single variable
1 parent 67c133f commit c74adfa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/views/EventList.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ export default {
2323
EventCard
2424
},
2525
created() {
26+
this.perPage = 3 // Setting perPage here and not in data means it won't be reactive
27+
// We don't need it to be reactive.
28+
2629
this.$store.dispatch('fetchEvents', {
27-
perPage: 3,
30+
perPage: this.perPage,
2831
page: this.page
2932
})
3033
},
@@ -33,7 +36,7 @@ export default {
3336
return parseInt(this.$route.query.page) || 1
3437
},
3538
isLastPage() {
36-
return this.eventsTotal > this.page * 3
39+
return this.eventsTotal > this.page * this.perPage
3740
},
3841
...mapState(['events', 'eventsTotal'])
3942
}

0 commit comments

Comments
 (0)