Export const variable undefined on response native

I defined some constant in Color.js but the color part is undefined when I call it on Screen.js

I am using a 0.4-bit based reaction for this project. Here is the code I wrote:

Color.js

export const ATHENS_GRAY = '#EDEEF0';
export const AQUA_SPRING = '#F8FBFD';
export const BLACK = '#000000';
export const BRIGHT_TURQUOISE = '#1BC1F1';
export const CATSKILL_WHITE = '#E4ECF4';
export const FROLY = '#F68181';
export const FUN_BLUE = '#1B61AD';
export const HIT_GRAY = '#A3AEB9';
export const JUMBO = '#7C7D80';
export const LIMED_SPRUCE = '#3D474C';

      

Screen.js

import React, {Component} from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import * as Color from './Color';

export default class Screen extends Component {
  constructor(props) {
    super(props);
    console.log(Color.BRIGHT_TURQUOISE);
    console.log(Color.FUN_BLUE);
  }

  render() {
    return (<View/>)
  }
}

      

Console.log result:

Color .BRIGHT_TURQUOISE undefined

Color .FUN_BLUE - '# 1B61AD'

Do you have an idea to solve this problem?

+3


source to share


1 answer


I tried it on my terminal using react-native log-android

and both values ​​come out like this:

enter image description here

Or maybe you can try another way to export your constant to yours Color.js

like this:



module.exports = Object.freeze({
   ATHENS_GRAY : '#EDEEF0',
   AQUA_SPRING : '#F8FBFD',
   BLACK : '#000000',
   BRIGHT_TURQUOISE : '#1BC1F1',
   CATSKILL_WHITE : '#E4ECF4',
   FROLY : '#F68181',
   FUN_BLUE : '#1B61AD',
   HIT_GRAY : '#A3AEB9',
   JUMBO : '#7C7D80',
   LIMED_SPRUCE : '#3D474C',
});

      

And you can try again :)

+2


source







All Articles