0

Consider this code:

import StaticComponent from './StaticComponent'

const Blog = component$(() => {

    let DynamicComponent = null
    try {
        import('SomePath')
            .then(temp => {
                DynamicComponent = temp
                console.log('Dynamic component is loaded successfully')
             })
            .catch(reason => console.error(reason)) || {}
    } catch (error) {
        console.error(error)
    }

    return DynamicComponent !== null
        ?
        <DynamicComponent {...data} />
        :
        <StaticComponent {...data} />
})

export default Blog

Basically I'm trying to load a dynamic component from a path, and if for any reasons (file is not there, or file is not valid, or other reasons) it's not loaded, I want to show a fallback UI (StaticComponent).

The point is that I only see the StaticComponent even when I see the log of successful import().

Why is it so? Why Qwik does not react to changing internal state of a component?

  • To me it doesn't really make sense. Qwik can do this for you without any complex code. The optimizer will create chunks anyway. You try to solve an issue what doesn't exist in qwik. Can you tell us more about your idea or concept? – Tob Apr 13 '23 at 14:59
  • @Tob - I have the same problem. I developed an infrastructure with the help of qwikjs so that every site that is built will use this infrastructure.I put the folder 'blob' and the file 'index.jsx' in the infrastructure related to user navigation, now I want to see here if in the site that uses the infrastructure, the component name is called 'layout' in the alias Is it imported to "blogports" from export or not? I should show this to the user, otherwise I should show the default component that is in the infrastructure. – Mohammad Miras Jul 10 '23 at 17:24
  • I don't know what to do for this problem, I was using dynamic import in other frameworks – Mohammad Miras Jul 10 '23 at 17:26

0 Answers0