Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ionic/Core 4.0.0-beta.11] Virtual Scroll example buggy #15653

Closed
kael opened this issue Sep 19, 2018 · 1 comment
Closed

[Ionic/Core 4.0.0-beta.11] Virtual Scroll example buggy #15653

kael opened this issue Sep 19, 2018 · 1 comment

Comments

@kael
Copy link

kael commented Sep 19, 2018

Bug Report

    "@ionic/core": "4.0.0-beta.11",
    "@stencil/core": "0.12.4"

Describe the Bug

Testing VirtualScroll with the recently modified example doesn't work. Seems some code is missing in the example, at least I can't make it work. This is what the compiler returns when running the example:

[ ERROR ]  TypeScript: src/components/app-home/app-home.tsx:16:4
           Type '(el: HTMLElement, cell: Cell) => void' is not assignable to type 'ItemRenderFn'. Type 'void' is not
           assignable to type 'HTMLElement'.

     L15:  virtual.items = items;
     L16:  virtual.nodeRender = (el, cell) => {
     L17:    if (cell.type === 0) {

Related Code
VirtualScroll works with the following changes:

     virtual.items = items;
     virtual.nodeRender = (el, cell) => {
       if (cell.type === 0) {
-        renderItem(el, cell.value);
+        return renderItem(el, cell.value);
       }
     };
     function renderItem(el, item) {
-      el.querySelector('ion-label').textContent = item;
+      if (!el) {
+        el = document.createElement('ion-item');
+        const labelEl = document.createElement('ion-label');
+        labelEl.textContent = item;
+        el.appendChild(labelEl);
+      } else {
+        el.querySelector('ion-label').textContent = item;
+      }
+      return el;
     }
   }

Am I missing something, perhaps related to the use of the new <template/> element ?

BTW, that'd be nice to have some doc about that new <template/>.

Addendum: The doc is not well formated (see the Usage section).

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 7, 2019

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

@ionitron-bot ionitron-bot bot closed this as completed Dec 7, 2019
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants