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

130
Visualizações
How is the JSX-compilation triggered?

I'm currently studying React and have set up a simple "Hello, world"-example:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello World</title>
    <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">

      ReactDOM.render( 
        <h1>Hello, world!</h1>,
        document.getElementById('root')
      );

    </script>
  </body>
</html>

BTW. I deliberately did not use a toolchain like create-react-app in order to understand the basics.

The following code snippet is actually something, that a web browser does not understand, because it's not standard JavaScript.

ReactDOM.render(<h1>Hello, world!</h1>, document.getElementById('root'));

It is JSX (JavaScript Syntax Extension), so it needs to be compiled. For example with Babel. I know that I included in the head of the html-file the Babel-compiler. But to me it is unclear when and how the actual compilation process takes place.

Is there a callback in the Babel-package that is called before the actual rendering and compiles the file in which it was via the <script src="">-tag included?

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

0

The Babel script performs the following:

  1. Adds a DOMContentLoaded listener
  2. Loads all the scripts if the scripts have a src
  3. Transforms the code and injects a <script> to evaluate the newly-transformed code.
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