之前设计时没注意,在服务端组件直接使用了:
import { useTranslations } from 'next-intl';
const t = useTranslations();
网页一直没出错,就没注意,但如果page设置成了async,就会出现[Error: Expected a suspended thenable. This is a bug in React. Please file an issue.]错误。
记着,服务端组件调用next-intl必须:
import { getTranslations } from 'next-intl/server';export default async function Home() {const t = await getTranslations();return (<div></div>);
}