Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Javascript TypeError: undefined no es un constructor (evaluando 'new _Team.GameTeam('name', 'null')')

Sigo recibiendo un TypeError cada vez que intento compilar en React Native. Aquí está la clase de la que estoy tratando de crear una instancia:

 class GameTeam { constructor(name, logoLocation) { this.name = name; this.logoLocation = logoLocation; }; getTeamName() { return this.name; } getTeamLogoLocation() { return this.logoLocation } }

y solo estoy creando con:

 const home = new GameTeam('name', 'null');

También intenté cambiar const a var y eso no ha hecho nada.

Si ayuda a resolver el problema, aquí está el archivo principalL

 import { GameTeam } from './objects/Team' import React from 'react'; import { Image, StyleSheet, Text, View } from 'react-native'; import { useFonts } from 'expo-font' import { VersusScore } from './components/VersusScore'; export default function App() { const home = new GameTeam('Tigers', 'null'); const away = new GameTeam('Raiders', 'null'); return ( <View style={mainStyles.container}> <View style={mainStyles.topBar}> <Image style={mainStyles.navIcon_small} source={require('./assets/Icons/Inactive/Settings_Icon.png')} /> <Text style={mainStyles.Title}>BRC</Text> <Image style={mainStyles.navIcon_small} source={require('./assets/Icons/Inactive/Announcements_Icon.png')} /> </View> <VersusScore homeTName={home} awayTName={away} /> </View> ); }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

La única diferencia que he visto con este y los documentos es que hay un; al final del constructor, que podría no dar un error de sintaxis, también podría impedir que funcione

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

about 4 years ago · Juan Pablo Isaza Report

0

Resulta que necesitaba cambiar class GameTeam para export default class GameTeam en el primer archivo, ya que era un archivo separado, ahora se ve así:

 export default class GameTeam { constructor(name, logoLocation) { this.name = name; this.logoLocation = logoLocation; } getTeamName() { return this.name; } getTeamLogoLocation() { return this.logoLocation } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!