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

104
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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