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

212
Vistas
React Native TypeError: undefined is not an object

I got the error while evaluating a const object, here's a minimal working example:

import React from "react";
import { View, StyleSheet } from "react-native";

const App = () => {
  return (
    <View style={styles.container}></View>
  );
}

const styles = StyleSheet.create({
  container: {
    backgroundColor:colors.bg,
  },
});

const colors = {
  bg:'blue',
}

export default App;

Error message: TypeError: undefined is not an object (evaluating 'colors.bg')

What's going on here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have to define colors const before the styles.

Try This

import React from 'react';
import {View, StyleSheet} from 'react-native';

const App = () => {
  return <View style={styles.container}></View>;
};

const colors = {
  bg: 'blue',
};

const styles = StyleSheet.create({
  container: {
    backgroundColor: colors.bg,
  },
});

export default App;
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