Lazy loaded image
技术分享
NextJS注意点
字数 305阅读时长 1 分钟
2024-12-24
2025-3-13
Last edited time
Mar 13, 2025 12:43 PM
type
status
date
summary
tags
password
URL
category

静态文件返回格式

注意如果你的静态文件是没有后缀的,nextjs将会无法判断文件格式,这种情况下你如果直接访问静态文件会自动下载。
需要在next.config.ts中配置相关字段。
比如基于public目录下的/.well-known/apple-app-site-association文件就需要做如下处理。

order of Hooks报错

React has detected a change in the order of Hooks called by LinkAI. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://react.dev/link/rules-of-hooks
如果遇到这个问题,需要注意你的界面代码中是否存在多个return,前面的return是否提前阻止了一些hooks的代码,这会导致后续代码无法执行从而报错。
解决方法
  1. 将return的不同情况放到代码最后部分
  1. 抽离出return另一种可能的逻辑到外层,将hooks统一放到内层。(推荐方式)
上一篇
FastAPI注意点
下一篇
Swift URL link注意点

评论
Loading...