我正在努力完成“反应原生轻松”教程,我遇到了一个问题。我正在运行eslint,我得到一个解析错误“意外令牌”。我的代码正是教程提供的。我不确定语法有什么问题。
import React, { Component } from 'react';
import { TextInput, View } from 'react-native';
import PropTypes from 'prop-types';
import styles from './TextArea.component.style';
class TextArea extends Component {
state = {
text : ''
}
render() {
const {...extraProps} = this.props;
return (
<TextInput
{...extraProps}
style={[styles.textArea, extraProps.style]}
multiline = {true}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>
);
}
}
export default TextArea;
我收到以下错误:
7:11 error Parsing error: Unexpected token =
这是我的.eslintrc.json文件:
{
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": ["error", 4],
"semi": [2, "always"],
"no-unused-vars": ["error", { "varsIgnorePattern": "TextInput|PropTypes"}],
"react/no-did-mount-set-state": 2,
"react/no-direct-mutation-state": 2,
"react/jsx-uses-vars": 2,
"no-undef": 2,
"react/prop-types": 2,
"react/jsx-no-bind": 2,
"react/jsx-no-duplicate-props": 2
}
}