嗨,当我第一次使用React-Native时出现意外的令牌错误:捆绑失败:"语法错误/Users/Lyle/SwcRN/SWCRN/App.js:意外的令牌(17:15)& #34;
这是我的App.js
import React from 'react';
import {
AppRegistry,
Text,
} from 'react-native';
import { StackNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
return <Text>Hello, Navigation!</Text>;
}
}
export default const SimpleApp = StackNavigator({
Home: { screen: HomeScreen },
});
AppRegistry.registerComponent('RNSWC', () => SimpleApp);
第17行是
export default const SimpleApp = StackNavigator({
我的package.json
{
...
"dependencies": {
"react": "16.0.0-alpha.12",
"react-clone-referenced-element": "^1.0.1",
"react-native": "0.48.3",
"react-native-cli": "^2.0.1",
"react-navigation": "^1.0.0-beta.11"
},
"devDependencies": {
"babel-jest": "^21.0.2",
"babel-preset-react-native": "^4.0.0",
"jest": "^21.1.0",
"react-test-renderer": "^16.0.0-alpha.12"
},
"jest": {
"preset": "react-native",
"verbose": true,
"setupFiles": [
"./jest/setup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-navigation)"
],
"moduleNameMapper": {
"^image![a-zA-Z0-9$_-]+$": "GlobalImageStub",
"^[@./a-zA-Z0-9$_-]+\\.(png|gif)$": "RelativeImageStub"
}
}
}
希望有所帮助,谢谢
答案 0 :(得分:3)
您应该像这样修改代码的第17行来解决问题:
const SimpleApp = StackNavigator({
Home: { screen: HomeScreen },
});