提问人:Satish Medapalli 提问时间:11/17/2023 更新时间:11/17/2023 访问量:17
如何纠正React代码中的解析错误
How to rectify the parse error in the React code
问:
// Write your code here
import {Component} from 'react'
import './index.css'
class Speedometer extends Component {
state = {count: 0}
Increase = () => {
const {count} = this.state
if (count < 200) {
this.setState(prevState => ({count: prevState.count + 10}))
}
}
Decrease = () => {
const {count} = this.state
if (count > 0) {
this.setState(prevState => ({count: prevState.count - 10}))
}
}
render() {
const {count} = this.state
return (
//html code
)
}
}
export default Speedometer
Error:
Failed to compile.
src/App.js
Line 1:25: Parse errors in imported module './components/Speedometer': Line 8: Missing semicolon.
6 | state= {count:0}
7 | Increase=()=>{
> 8 | this.prevState=>({prevState.count+10})
| ^
9 | }
10 | render() {
11 | const {count}=this.state (8:19) import/no-named-as-default
Line 1:25: Parse errors in imported module './components/Speedometer': Line 8: Missing semicolon.
我已经尝试了几次尝试来修复此错误,但找不到解析错误。特别是在 8 行的箭头函数不知道为什么会出现错误。实际上什么是解析错误?
答: 暂无答案
评论