我很困惑,为什么我的箭头函数不能导出。我收到了 "解析错误。"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};