ReactJS: Ошибка синтаксического анализа: экспорт «NextQuestion» не определен - PullRequest
0 голосов
/ 19 июня 2020

Я не понимаю, почему мои стрелочные функции не экспортируются. Я получил сообщение об ошибке «Ошибка анализа: экспорт« NextQuestion »не определен», и я не уверен, почему. Вот мой код:

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};

1 Ответ

0 голосов
/ 19 июня 2020

Вы должны определить свои переменные, использовать 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};
...