ReactJS: Parsing error: Export "NextQuestion" is not defined
ReactJS: Parsing error: Export "NextQuestion" is not defined
我很困惑为什么我的箭头函数没有导出。我收到了错误 "Parsing error: Export 'NextQuestion' is not defined",但不确定原因。这是我的代码:
import React, { Component } from "react"
NextQuestion = () => {
var neww = true
this.setState((state) => {
return {continue: neww}
}
)
}
LostALife = () => {
var newLives = this.state.lives - 1
this.setState((state) => {
return {lives: newLives}
}
)
}
export {NextQuestion, LostALife};
你应该定义你的变量,使用const NextQuestion,你可以看到下面更新的代码
import React, { Component } from "react"
const NextQuestion = () => {
var neww = true
this.setState((state) => {
return {continue: neww}
}
)
}
const LostALife = () => {
var newLives = this.state.lives - 1
this.setState((state) => {
return {lives: newLives}
}
)
}
export {NextQuestion, LostALife};
我很困惑为什么我的箭头函数没有导出。我收到了错误 "Parsing error: Export 'NextQuestion' is not defined",但不确定原因。这是我的代码:
import React, { Component } from "react"
NextQuestion = () => {
var neww = true
this.setState((state) => {
return {continue: neww}
}
)
}
LostALife = () => {
var newLives = this.state.lives - 1
this.setState((state) => {
return {lives: newLives}
}
)
}
export {NextQuestion, LostALife};
你应该定义你的变量,使用const NextQuestion,你可以看到下面更新的代码
import React, { Component } from "react"
const NextQuestion = () => {
var neww = true
this.setState((state) => {
return {continue: neww}
}
)
}
const LostALife = () => {
var newLives = this.state.lives - 1
this.setState((state) => {
return {lives: newLives}
}
)
}
export {NextQuestion, LostALife};