So I know this question has been asked a few time but I can't find a solution which is working for me and I don't understand how does this properly work.
Here is the function involved :
import form from "./form"; //return some html
function changePage(e){
console.log(e.target.dataset.component) // equal "form"
//loadComponent(form) => is working
loadComponent(eval(e.target.dataset.component)) // => form is not defined
}
function loadComponent(name)
{
const wtv = name()
document.getElementById('app').append(wtv)
}
So how can I dynamicaly call e.target.dataset.component
?