Custom theme component doesn't show on first render

I created a simple component that will display a simple clickable banner for the login users. It works fine until I upgrade to 2.9.0.beta5: Security Fixes, Block Hotlinked Media, PM Tagging, Search Improvements, and more

The component only shows up when I refresh the page 2~3 times and it will disappear every time when I open my site in a new tab/window. I see the same issue happens on theme-creator.

Any idea why this happens? Following is the code I use.

<script type="text/discourse-plugin" version="0.8">
const h = require("virtual-dom").h;

let user = api.getCurrentUser();

if(user){
 api.createWidget("fixed-banner", {
     tagName: "div.container-row",

     html() {
         return h('div.content', [
             h('a.bannerLink', {
                href: '/categories',
             }, 'test'),
    ]);
     }
 });
  
}
</script>
1 Like

Find why, I used to put

<script type="text/x-handlebars" data-template-name="/connectors/above-site-header/theme-component">
    {{mount-widget widget="theme-component"}}
</script>

in <body> tag, moving to head tag fixed this issue. But it’s weird that the issue suddenly happen after recent upgrade, it used to work fine.