我正在将一个项目从next.js 7迁移到 10。它使用react-intl进行翻译,并且是用 TypeScript 编写的。
在以前的版本我有一个自定义的server.js和处理子路由多语言的目的(/日,/ FR等),在它。在自定义应用程序组件中,通过 getInitialProps,我从req获取语言环境并将其作为道具传递给我的组件。所以整个画面是这样的:
自定义应用程序:
static async getInitialProps({ Component, ctx }) {
let pageProps = {}
const { req } = ctx;
const { locale, messages } = req || (window as any).__NEXT_DATA__.props;
const initialNow = Date.now();
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return { pageProps, locale, messages, initialNow }
}
Run Code Online (Sandbox Code Playgroud)
和组件
render() {
const { Component, pageProps, locale, messages, initialNow …Run Code Online (Sandbox Code Playgroud) 我需要添加一个空迁移来编写 SQL 查询并手动操作数据。
我的架构没有变化,基本上,我只需要将此查询应用于我的现有数据。