Destroy widgets in single page app


#1

I’m currently using a custom component to embed timelines into our single page app, basically it runs

    twttr.ready(() => {
      twttr.widgets.createTimeline({
        sourceType: 'profile',
        screenName: this.screenName
      }, this.elem.nativeElement);
    });

on the element of the component, however, after a page change twitter throws:

Uncaught TypeError: Cannot read property 'classList' of null
    at Object.u [as present] (https://platform.twitter.com/widgets.js:8:12718)
    at t.hasRootClass (https://platform.twitter.com/widgets.js:9:11665)
    at t.recalculateBreakpoints (https://platform.twitter.com/widgets.js:10:15527)
    at t.<anonymous> (https://platform.twitter.com/widgets.js:10:15752)
    at t.<anonymous> (https://platform.twitter.com/widgets.js:9:7106)
    at t.resize (https://platform.twitter.com/widgets.js:9:7017)
    at t.<anonymous> (https://platform.twitter.com/js/timeline.49f19f9e34b1f8ffe443c6d5e80fea48.js:1:17652)
    at t.loadNewTweets (https://platform.twitter.com/widgets.js:9:7106)
    at https://platform.twitter.com/js/timeline.49f19f9e34b1f8ffe443c6d5e80fea48.js:1:18616

It seems there is no destroy method to let the library know that the container has been removed from the dom right? Any idea?


Timeline Widget not destroyed on single page application page change SPA
#2

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.