I have an import.js and I am writting all modules' path in there. For example. color.js and button.js is recognized in import.js. And then I want to call my imports from there in the other components. And I can call all modules' imports in the main.js. But in button.js , I can't call color.js When one of js file is imported in import.js, It can't call any js file in import.js. Also It is giving this error:
1.undefined is not an object (evaluating 'COLOR.BUTTONDARK')
2.[fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'COLOR.BUTTONDARK')
3.[error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module.
//import.js module.exports = { BUTTON: require('./../components/XYZButton'), COLOR: require('./../styles/colors'), }; //colors.js module.exports = { BUTTONDARK: '#084C6E', TEXTLIGHT: '#FFFFFF' }; //xyzbutton.js const COLOR = require('./../constants/imports'); class XYZButton extends React.Component { render() { return ( <TouchableHighlight> <View style={{backgroundColor:COLOR.BUTTONDARK}}> <Text style={{color:COLOR.TEXTLIGHT}}> {'TEST'} </Text> </View> </TouchableHighlight> ); } } module.exports = (XYZButton); //main.js const {BUTTON, COLOR} = require('./../../../../constants/imports'); class Main extends React.Component { render() { return ( <View style={{backgroundColor:COLOR.BUTTONDARK}}> <BUTTON onPress = {() => { this._handleSelectModulPage() }} style = {{ alignItems: 'center', justifyContent: 'center' }} /> </View> ); } } module.exports = (Main);