import { useState } from "react";
const TronWeb = require("tronweb");
const [lpLogged, setlpLogged] = useState(true);
async function getTronWeb() {
if (window.tronWeb && window.tronWeb.defaultAddress.base58) {
return window.tronWeb;
}
return null;}
let curweb = getTronWeb ();
async function initWindow() {
if (curweb == null) {
setlpLogged((lpLogged) => false);
alert.show("We were unable to find any suitble providder.");
} else {
setlpLogged((lpLogged) => true);
}
}
<button onclick={initWindow}>Can you get tronweb from tronlink?</button> Compiled with problems:X错误在./src/App.js 12:35-39
导出'default‘(导入为'Body')在'./components/Body’中找不到(模块没有导出)
错误
eslint src\components\Body.js 8:33: React "useState“不能在顶层调用。必须在React函数组件或自定义React函数React /rules of Hooks中调用react。
搜索关键字以了解更多关于每个错误的信息。
这是我在运行时所面临的错误。
发布于 2022-06-29 15:39:30
尝试修复导入:,{useState}从" React ";
加上检查车身组件中的导出方法
https://stackoverflow.com/questions/72804102
复制相似问题