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

0.16.0 Invariant Violation: Element type is invalid: expected a string #29

Closed zhuchaowe closed 8 years ago

zhuchaowe commented 8 years ago

2015-12-06 15:39:32.406 [error][tid:com.facebook.React.RCTExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

I got this Exception when use<TabNavigator></TabNavigator> , in react-native 0.16.0

zhuchaowe commented 8 years ago

ok , I fix this Exception use import TabNavigator from 'react-native-tab-navigator' instead of var TabNavigator = require("react-native-tab-navigator")

ide commented 8 years ago

For people reading this issue: I believe that import and export changed in Babel 6, and react-native 0.16 is the first version of RN to use Babel 6.

The thing that changed is that when you write export default Foo, this sets exports.default = Foo and doesn't set exports = Foo anymore. This means that if you try to require react-native-tab-navigator, you need to access require('react-native-tab-navigator').default or write import 'react-native-tab-navigator'.