0
votes

I am getting this error :

Cannot read property 'map' of undefined new index.android.bundle?platform=android&dev=false&hot=false&minify=false:87221:34 ReactCompositeComponentWrapper._constructComponentWithoutOwner index.android.bundle?platform=android&dev=false&hot=false&minify=false:31251:30 ReactCompositeComponentWrapper._constructComponent index.android.bundle?platform=android&dev=false&hot=false&minify=false:31247:21 ReactCompositeComponentWrapper.mountComponent index.android.bundle?platform=android&dev=false&hot=false&minify=false:31231:25 Object.mountComponent index.android.bundle?platform=android&dev=false&hot=false&minify=false:30937:39 Object.updateChildren index.android.bundle?platform=android&dev=false&hot=false&minify=false:32163:69 Constructor._reconcilerUpdateChildren index.android.bundle?platform=android&dev=false&hot=false&minify=false:32271:119 Constructor._updateChildren index.android.bundle?platform=android&dev=false&hot=false&minify=false:32308:33 Constructor.updateChildren index.android.bundle?platform=android&dev=false&hot=false&minify=false:32302:14 Constructor.receiveComponent index.android.bundle?platform=android&dev=false&hot=false&minify=false:32375:119

main.js

 import icons from './icons'       

  type Cell = {
      image: any,
      animation: any
    };

    export default class Camera extends React.Component {
      cells: Cell[];
      background = new Animated.Value(HIDDEN);
      text = new Animated.Value(HIDDEN);
      state: { focused?: Cell } = {};

      constructor(props) {

        super(props);
        this.cells = icons.map((icon) => ({
          ...icon, animation: new Animated.Value(HIDDEN)
        }));


      }

icons.js

import React from 'react';
import Icon from 'react-native-vector-icons/Octicons'
import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'

const icons =[
  { name: 'Notes', image: <Icon name='device-camera' />},
  { name: 'Earth', image: <SimpleLineIcons name='camera' /> }
]

export { icons }
1
Did you log icons, looks like it's undefined - adeneo
@adeneo yea, its showing undefined, don't know why ? - YaSh Chaudhary
Then import icons from './icons' probably isn't doing what you think it's doing. - adeneo
@adeneo or maybe export { icons } not working , don't know where is the issue. - YaSh Chaudhary
Neither do I, or anyone else for that matter, if the issue is that icons isn't imported properly ? - adeneo

1 Answers

3
votes

export default icons; within icons.js should do the trick.