设置状态时出现语法错误
I get syntax error while setting the state
我正在尝试像这样在 Next.js 中设置初始状态:
constructor(props: Props) {
super(props);
const emptyContract = new ethers.Contract(
"",
"",
new ethers.providers.JsonRpcProvider("")
);
this.state = {
account: "0x0",
blockchainDataLoaded: false,
futNFT: emptyContract,
futNFTMatch: emptyContract,
futNFTTraining: emptyContract,
futNFTTransfer: emptyContract,
vrfConsumer: emptyContract,
};
}
但是我得到这个错误:SyntaxError: Unexpected end of JSON input
Contract 构造函数的第二个参数是一个数组,因此替换为:
const emptyContract = new ethers.Contract(
"",
"",
new ethers.providers.JsonRpcProvider("")
);
与:
const emptyContract = new ethers.Contract(
"",
[],
new ethers.providers.JsonRpcProvider("")
);
我正在尝试像这样在 Next.js 中设置初始状态:
constructor(props: Props) {
super(props);
const emptyContract = new ethers.Contract(
"",
"",
new ethers.providers.JsonRpcProvider("")
);
this.state = {
account: "0x0",
blockchainDataLoaded: false,
futNFT: emptyContract,
futNFTMatch: emptyContract,
futNFTTraining: emptyContract,
futNFTTransfer: emptyContract,
vrfConsumer: emptyContract,
};
}
但是我得到这个错误:SyntaxError: Unexpected end of JSON input
Contract 构造函数的第二个参数是一个数组,因此替换为:
const emptyContract = new ethers.Contract(
"",
"",
new ethers.providers.JsonRpcProvider("")
);
与:
const emptyContract = new ethers.Contract(
"",
[],
new ethers.providers.JsonRpcProvider("")
);