question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useVirtualList with Vue2 - list is not reactive

See original GitHub issue

Describe the bug

I’m using Vue2 and useVirtualList does not render anything. list stays empty.

Ref #1078 (#951 Vue3)

Reproduction

https://stackblitz.com/edit/vitejs-vite-uuio2f

System Info

Stackblitz template; 


{
  "name": "vite-starter",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview",
    "postinstall": "vue-demi-fix"
  },
  "dependencies": {
    "@vue/composition-api": "^1.4.9",
    "@vueuse/components": "^7.7.1",
    "@vueuse/core": "^7.7.1",
    "vue": "^2.6.14",
    "vue-demi": "^0.12.1"
  },
  "devDependencies": {
    "vite": "^2.8.6",
    "vite-plugin-vue2": "^1.9.3",
    "vue-template-compiler": "^2.6.14"
  }
}

Used Package Manager

npm

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
johanneslo1commented, Sep 7, 2022

I had to add the scroll event manually too. I’m using Vue 2.7.2.

In <script setup>:

const { list, containerProps, wrapperProps } = useVirtualList(filteredList, {
  itemHeight: 22,
});

const containerRef = containerProps.ref;

In <template>

<div
      ref="containerRef"
      style="height: 300px; overflow-y: auto;"
      @scroll="containerProps.onScroll"
    >
      <div v-bind="wrapperProps">
        <div v-for="item in list" :key="item.index" style="height: 22px">
          Row: {{ item.data }}
        </div>
      </div>
    </div>
0reactions
johannes-zcommented, Nov 14, 2022

not completed

Read more comments on GitHub >

github_iconTop Results From Across the Web

useVirtualList
Create virtual lists with ease. Virtual lists (sometimes called virtual scrollers) allow you to render a large number of items performantly.
Read more >
Items added to list are non-reactive in version 2 of Vue.js
If I were you, I'd create a method and just do this.items.push({ id: null, name: '' }) . There's no need to clone...
Read more >
v-for performance issue · Issue #2000 · vuejs/vue
Render time in my case was reduced from 2 seconds to 100ms (aprox) ... @nkostadinov have you tried not using reactive data for...
Read more >
Create a performant virtual scrolling list in Vue.js
In this article, we'll explore vue-virtual-scroll-list , an amazing library for creating virtual scroll lists in Vue.js. Let's get started!
Read more >
Svelecte - select with autocomplete written in Svelte
Property Type Default name string null options array valueAsObject bool false
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found