Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda