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

96
Visualizações
Babel React transpiling to `fileName.Component` instead of just `Component`

I am having to call my react component as component.Component, like below. Also to note, the first part is the file name. If the rename the file, I have to say (newFileName.LikeButton). enter image description here

instead of

ReactDOM.render(React.createElement(LikeButton) , domContainer);

Any idea how I can resolve this? Here is my setup. My babel.config.json

{
    "presets": ["@babel/preset-react", "@babel/preset-env" ],
    "plugins": [ "@babel/plugin-transform-modules-umd" ]
}

my react component in likeButton.jsx

export class LikeButton extends React.Component {
  constructor(props) {
    super(props);
    this.state = { liked: false };
  }
 
  render() {
    if (this.state.liked) {
      return 'You liked this.';
    }

    return (<button onClick={() => this.setState({ liked: true }) }>
        Like
      </button>
      );
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Warning, this answer is speculative (but too long for a comment)

I suspect your imports look something like this:

import likeButton from './somePath/likeButton'

but, because you are using named exports, (as opposed to default exports), your import should actually look like:

import { LikeButton } from './somePath/likeButton'

to "destructure" LikeButton from the module.

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