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

111
Vistas
Javascript TypeError: undefined is not a constructor (evaluating 'new _Team.GameTeam('name', 'null')')

I keep getting a TypeError whenever I attempt to compile in React Native. Here is the class I'm trying to create an instance of:

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

    getTeamName() {
        return this.name;
    }

    getTeamLogoLocation() {
        return this.logoLocation
    }
}

and I'm just creating with:

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

I've also tried change const to var and that hasn't done anything.

If it helps solve the issue at all, here's the main fileL

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

0

Only difference I have seen with this one and the docs is that there is a ; at the end of constructor which might not give syntax error might also block it from working

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

about 4 years ago · Juan Pablo Isaza Denunciar

0

Turns out I needed to change class GameTeam to export default class GameTeam in the first file, since it was a separate file, now it looks like this:

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 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