gpt4 book ai didi

javascript - Invariant Violation Invalid hook call 部署错误

转载 作者:行者123 更新时间:2023-12-04 17:37:05 24 4
gpt4 key购买 nike

我的应用程序在最后一次提交之前一直按方面工作。

现在它在 npm start 上运行良好,但是在使用 npm run builder 部署它之后我得到了运行时错误:

Invariant Violation: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Uncaught Invariant Violation: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Errors Screen Shot

这会导致 Invalid Hook Error

Invalid hook call. Hooks can only be called inside of the body of a function component.

为了尝试解决这个问题,我添加了 eslint 规则 "react-hooks/rules-of-hooks": "error"

我的项目似乎没有Invalid hooks 错误(如前所述,它在npm start 上运行良好)。

//package.json
"scripts": {
"start": "NODE_PATH=src/ PORT=9050 react-app-rewired start",
"builder": "NODE_PATH=src/ react-app-rewired --max_old_space_size=4096 build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"build": "./dockerfile/build.sh simulator",
"start:server": "node ./server/server.js",
}

知道如何修复部署错误吗?

最佳答案

通过升级 react-scriptsnpm install react-scripts@latest 解决。

然后,您应该清除缓存(开发工具中的Application 选项卡)并重新加载(Ctrl+Shift+R)

关于javascript - Invariant Violation Invalid hook call 部署错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56251774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com