Repository navigation
Infinite Table updates? #191
Description
Activity
This might be caused by values bound to
<b-slot-component>, which are return values of methods; i.e., a brand new object is created every time the method is called.buefy-next/packages/buefy-next/src/components/table/Table.vue
Lines 318 to 332 in 185589f
<b-slot-component :component="column" v-bind="column.tdAttrs(row, column)" scoped name="default" tag="td" :class="column.getRootClasses(row)" :style="column.getRootStyle(row)" :data-label="column.label" :props="{ row, column, index, colindex, toggleDetails, isActiveDetailRow }" @click="$emit('cellclick',row,column,index,colindex)" /> I found a case where the recursion error disappeared if I removed all of the
v-bind,:class, and:stylebindings.Reacted by Wesley FordThis might be caused by values bound to
<b-slot-component>, which are return values of methods; i.e., a brand new object is created every time the method is called.buefy-next/packages/buefy-next/src/components/table/Table.vue
Lines 318 to 332 in 185589f
<b-slot-component :component="column" v-bind="column.tdAttrs(row, column)" scoped name="default" tag="td" :class="column.getRootClasses(row)" :style="column.getRootStyle(row)" :data-label="column.label" :props="{ row, column, index, colindex, toggleDetails, isActiveDetailRow }" @click="$emit('cellclick',row,column,index,colindex)" /> I found a case where the recursion error disappeared if I removed all of the
v-bind,:class, and:stylebindings.As a result did the CPU usage go down to?
As a result did the CPU usage go down to?
@wesdevpro I was not able to measure the CPU usage because I just ran a tiny Vitest test case.
Reacted by Wesley FordAs a result did the CPU usage go down to?
@wesdevpro I was not able to measure the CPU usage because I just ran a tiny Vitest test case.
That makes sense
@kikuomax do you want to tackle this issue in v0.2.0 or v0.2.1?
@wesdevpro I think that fixing this issue should be tough. Although it is a difficult decision as this bug is critical, let's put this issue in the v0.2.1 milestone to finish the TypeScript migration as soon as possible.
Reacted by Wesley FordI found the problem was caused by passing an arrow function to the
td-attrsprop inTableColumn.spec.ts.
<BTableColumn :td-attrs="(td) => ({ id: \`td-\${td.id}\` })" v-slot="props"> If I replaced the arrow function with a component instance method
tdAttrs, the error disappeared.const DetailedTable = { template: ` <BTable :data="tableData" detail-key="id" detailed> <BTableColumn :td-attrs="tdAttrs" v-slot="props"> <div> {{ props.row.name }} - {{ props.isActiveDetailRow(props.row) ? 'Opened' : 'Closed' }} </div> <BButton @click="props.toggleDetails(props.row)">Toggle details</BButton> </BTableColumn> </BTable>`, components: { BTable, BTableColumn, BButton }, methods: { tdAttrs(td: { id: string }) { return { id: `td-${td.id}` } } } }
I need some investigation and thinking to understand why this matters.
If we specify an inline arrow function to a prop, the prop is detected as changed every time the host component is evaluated. See this comment in the Vue.js core repo.
I slipped a few lines for tracing update events and data changes. If I ran the test, I got the following output:
Table visibleColumns changed Table beforeUpdate TableColumn tdAttrs changed TableColumn beforeUpdate Table beforeUpdate TableColumn tdAttrs changed TableColumn beforeUpdate Table beforeUpdate ... truncated ... TableColumn tdAttrs changed TableColumn beforeUpdate TableColumn updated Table updated [Vue warn]: Maximum recursive updates exceeded in component <BTable>. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.If I replaced
tdAttrsin the test component with a component instance method, I got the following trace:Table visibleColumns changed Table beforeUpdate Table updatedMy hypothesis of how the infinite updates happen:
Tableis watchingTableColumnspecified to its default slot because it listsTableColumnin thevisibleColumnscomputed value. Meanwhile,TableColumnis detected as changed every time it is evaluated, because an inline arrow function is specified to itstdAttrsprop (see this comment in the Vue.js core repo). WheneverTableenumerates items in thevisibleColumnscomputed value, it will trigger an update ofTableitself due toTableColumn's change, and thenTableends up with infinite updates.I will fix the spec and add a warning message to the documentation to tell the consequence of specifying an inline arrow function to the
tdAttrsprop.Reacted by Wesley Ford- added a commit that references this issue
on Mar 1, 2025 - moved this from 🏗 In progress to Pending Release🔦 in Buefy-next Vue3 Project Board
on Apr 3, 2025
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsPending Release🔦
Overview of the problem
Buefy version: [0.1.2]
Vuejs version: [3.3.7]
OS/Browser: macOS/test-utils
Description
Tablecaused infinite updates of reactive states.Steps to reproduce
cd packages/buefy-nextnpx jest src/components/table/TableColumn.spec.jsExpected behavior
No infinite updates.
Actual behavior
Infinite updates.