I encounter a strange issue when I export
a const
to another js file. Here is my issue:
Imagine I have two files named index.js
and router.js
.
// in router.js
export const stackNav = StackNavigator({
Home: {
screen: Me,
navigationOptions: {
title: 'Welcome'
}
}
});
// in index.js
import { stackNav } from './router';
class MainApp extends Component {
render() {
return (
<stackNav />
);
}
}
export default MainApp;
When I use the above code to run, I fail to run my app and it shows error message with red screen: Expected a component class, got [object Object].
However, if I change all stackNav
to StackNav
, I can run my app successfully. So, I don't know why the case of the name/identifier matters?