我尝试在封装的request.ts文件中使用国际化,如果使用
import { formatMessage } from 'umi';
会报如下警告:
devScripts.js:5035 Warning: Using this API will cause automatic refresh when switching languages, please use useIntl or injectIntl.
使用此 api 会造成切换语言的时候无法自动刷新,请使用 useIntl 或 injectIntl。
我尝试使用useIntl,报错如下:
react-dom.development.js:14724 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app
What happens?
我尝试在封装的request.ts文件中使用国际化,如果使用 import { formatMessage } from 'umi'; 会报如下警告: devScripts.js:5035 Warning: Using this API will cause automatic refresh when switching languages, please use useIntl or injectIntl. 使用此 api 会造成切换语言的时候无法自动刷新,请使用 useIntl 或 injectIntl。
我尝试使用useIntl,报错如下: react-dom.development.js:14724 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
我理解的大致意思就是在非组件的ts文件中无法使用,我想问的是,我在request.ts文件中如何使用国际化,因为这只是我封装的调接口的ts文件并不是react组件,某些提示框需要做国际化,应该怎么操作呢?
Mini Showcase Repository(REQUIRED)
How To Reproduce
Steps to reproduce the behavior: 1. 2.
Expected behavior 1. 2.
Context