Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

92
Visualizações
Is it possible to append JSX at runtime?

I have a stencil component that needs to append a child to a slotted node. Currently I do it like this:

const x = document.createElemet('x');
slotted.appendChild(x);

But I want to do something like this:

const xJsx = (<x></x>);
slotted.appendChild(xJsx);

The latter won't work because appendChild expects an Node, HTMLElement or DocumentFragement but is there a way to convert the JSX and append it at runtime using stencil?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Generally no you can't

To elaborate:

JSX is just a syntax, it only exists when you are at an editor writting code, it helps you write this specifc language which is easy to understand by human and later can be translated to javascript and html tags.

When you say runtime, you are refering to browser's javascript runtime, browser's JS engine don't know what is JSX. As a result it doesn't work.

Now here's what babel come to the play: it translates your JSX syntax code into javascript that browser support. And it happens in build time. (you prebuild it)

The reason I said "Genrally" is, no one stops a person try to use babel to transpile JSX in browser with some hack... however I personally wouldn't recommand it since it's very inefficient and need a lot of work to have it working

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda