ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 415 forks source link

wired problem after update to react native 0.16 #31

Closed sospartan closed 8 years ago

sospartan commented 8 years ago

I got an error with latest tab navigator and react native 0.16:
screen shot 2015-12-07 at 7 54 18 pm
My code:

var TabBar = Platform.OS === 'ios'?React.TabBarIOS:require('react-native-tab-navigator');
var TabNavigator = React.createClass({
  getInitialState: function() {
    return {
      selectedIndex: 0,
    };
  },
    _isCurrentTab:function(index){
        //console.log(""+this.state.selectedIndex+"==="+index);
        return this.state.selectedIndex===index;
    },
  render: function() {
      //... tabs is just a array of <TabBar.Item/>

      return (
          <TabBar style={{backgroundColor:'black'}}>
              {tabs}
          </TabBar>
      );
  },
});

Nothing special . I think. After some hours for searching reason. I found a work around:
in 'TabNavigator.js' , remove export default and use module.exports = TabNavigator; to export the module . I'm a js newbie , not sure it's a js or react native problem , or just related to this module.

timzaak commented 8 years ago

30 this will help you

ide commented 8 years ago

Thanks @timzaak.

Use ES6 import instead of CommonJS require. I'll add this to the README for clarity.

sospartan commented 8 years ago

Thanks @timzaak .