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

prefetch.setComponents is not a function #1

Open
DanielHabenicht opened this issue Dec 17, 2020 · 3 comments
Open

prefetch.setComponents is not a function #1

DanielHabenicht opened this issue Dec 17, 2020 · 3 comments

Comments

@DanielHabenicht
Copy link

DanielHabenicht commented Dec 17, 2020

Hi I have implemented your component as stated in the readme but it is not working and resulting in this error:

index-93a5cbbe.js:2695 TypeError: prefetch.setComponents is not a function
    at DashjsSettingsControl.componentDidLoad (dashjs-settings-control.entry.js:115)
    at safeCall (index-93a5cbbe.js:1538)
    at postUpdateComponent (index-93a5cbbe.js:1456)
    at postUpdate (index-93a5cbbe.js:1391) undefined

Thanks a lot and hope we can resolve the error.

My Component:

import { Component, h, Host, Build, Element } from '@stencil/core';

@Component({
  tag: 'dashjs-reference-ui',
  styleUrl: 'dashjs-reference-ui.css',
  shadow: false,
})
export class DashjsReferenceUi {
  @Element() el: HTMLElement;
  componentDidLoad() {
    const componentsConfig = [
      {
        tag: 'dashjs-settings-control-modal',
        props: {
          prefetching: true,
        },
      },
      {
        tag: 'ion-modal',
        props: {
          prefetching: true,
        },
      },
      {
        tag: 'ion-content',
        props: {
          prefetching: true,
        },
      },
      {
        tag: 'ion-searchbar',
        props: {
          prefetching: true,
        },
      },
      {
        tag: 'ion-content',
        props: {
          prefetching: true,
        },
      },
      {
        tag: 'ion-grid',
        props: {
          prefetching: true,
        },
      },
      {
        tag: 'ion-row',
        props: {
          prefetching: true,
        },
      },
    ];

    if (Build.isBrowser) {
      // only pre-fetch if it's a real browser
      const prefetch = this.el.querySelector('stencil-component-prefetch') as any;

      prefetch.setComponents(componentsConfig);
    }
  }
  render() {
    return (
      <Host>
        <stencil-component-prefetch />
        <dashjs-api-control></dashjs-api-control>
        <dashjs-settings-control onSettingsUpdated={event => console.log(event)}></dashjs-settings-control>
        <dashjs-player stream-url={''}></dashjs-player>
        <dashjs-statistics></dashjs-statistics>
      </Host>
    );
  }
}
@beck24
Copy link
Owner

beck24 commented Dec 17, 2020

The implementation looks correct - have you included it as a dependency?

npm install @beck24/stencil-component-prefetch

Have you imported it into your project?

import * from '@beck24/stencil-component-prefetch'

@DanielHabenicht
Copy link
Author

Importing fixes it. I think the confusion is coming from the import not being mentioned in the Readme.

@Agular
Copy link

Agular commented Apr 19, 2024

Yep, it's missing in the Readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants