小编cor*_*ese的帖子

useEffect 在 Nextjs Typescript 应用程序中被调用两次

我有一个简单的 useEffect 函数设置,带有括号,如下所示:

  useEffect(() => {
    console.log('hello')
    getTransactions()
  }, [])
Run Code Online (Sandbox Code Playgroud)

但是,当我运行我的应用程序时,它会在控制台中打印两个hello。知道为什么吗?

即使我添加这样的内容,仍然会打印两个hello。

  const [useEffectCalled, setUseEffectCalled] = useState<Boolean>(false)

  useEffect(() => {
    console.log('hello')
    if (!useEffectCalled) {
      getTransactions()
    }
    setUseEffectCalled(true)
  }, [])
Run Code Online (Sandbox Code Playgroud)

javascript frontend reactjs next.js

13
推荐指数
1
解决办法
1万
查看次数

如何使用以太币连接到自定义提供商?

如何使用ethers包使用自定义节点 url 创建新的 Provider?

想做这样的事情:

 const provider = new ethers.providers.Web3Provider('http://my-node.com')
Run Code Online (Sandbox Code Playgroud)

javascript ethereum ethers.js

7
推荐指数
1
解决办法
1万
查看次数

类型错误:在 Vercel 中部署时找不到模块“firebase-functions”或其相应的类型声明

我有一个 nextjs 和 firebase 应用程序设置,具有功能,并且所有内容都可以在本地完美运行和构建。但是,当我构建并部署到 Vercel 时,我在 Vercel 控制台中收到以下构建错误:

类型错误:找不到模块“firebase-functions”或其相应的类型声明。

在此输入图像描述

这是我的应用程序/功能 package.json

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "axios": "^0.26.1",
    "firebase": "^9.6.11",
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^3.18.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": …
Run Code Online (Sandbox Code Playgroud)

firebase typescript next.js vercel

5
推荐指数
1
解决办法
1856
查看次数

How to pass File to Firebase Functions

I'm trying to pass a file (image) from my Reactjs app to Firebase Functions to then upload it to Pinata using their Node.js sdk but my cloud function keeps returning: ERR_INVALID_ARG_TYPE

Is it possible to pass a file to Firebase Functions?

I need to eventually convert it to a readable stream to use Pinata.

Image file: 在此输入图像描述

node.js firebase reactjs google-cloud-functions pinata

1
推荐指数
1
解决办法
650
查看次数