【发布时间】:2018-06-04 09:34:59
【问题描述】:
我试图让Tech Stack 出现在iOS 模拟器的顶部。相反,我的两个 .js 文件都出现了一个奇怪的错误,尽管它们在语法上看起来是正确的。
错误提示:unexpected block statement surrounding arrow body arrow-body-style 在两个 .js 文件上。
我偶然发现了这个网站https://eslint.org/docs/rules/arrow-body-style 以获取更多信息并彻底搜索解决方案,但找不到任何东西。
(错误的位置在两个.js文件中都有注释)
我该如何解决这个问题?
模拟器出错:
这里是app.js:
import React from 'react';
import { View } from 'react-native';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';
import { Header } from './components/common';
const App = () => { // error is on this line
return (
<Provider store={createStore(reducers)}>
<View>
<Header headerText="Tech Stack" />
</View>
</Provider>
);
};
export default App;
这里是CardSection.js
import React from 'react';
import { View } from 'react-native';
const CardSection = (props) => { // error is on this line
return (
<View style={styles.containerStyle}>
{props.children}
</View>
);
};
const styles = {
containerStyle: {
borderBottomWidth: 1,
padding: 5,
backgroundColor: '#fff',
justifyContent: 'flex-start',
flexDirection: 'row',
borderColor: '#ddd',
position: 'relative'
}
};
export { CardSection };
【问题讨论】:
标签: javascript reactjs react-native jsx eslint