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?