![](/img/trans.png)
[英]How to use injectIntl from react-intl and typescript together?
[英]Use typescript with react-intl
我在 mu 應用程序react-intl
中使用。 我有下一個代碼:
const intl = useIntl(); const test = makeTest(error, intl.formatMessage); // call test in another file: const run = (error: ApolloError, formatMessage): string => {... };
你怎么能看到我在我的反應應用程序中使用formatMessage
,但是當我想從const run = (error: ApolloError, formatMessage): string
問題。
我搜索了不同的來源,但我無法輸入該參數,如何輸入formatMessage
?
useIntl
的返回類型可以在 IDE 或源代碼https://github.com/awoodworth/react-intl/blob/master/src/components/useIntl.ts中查找
類型最終是
import { MessageDescriptor } from 'react-intl';
const run = (error: ApolloError, formatMessage: (descriptor: MessageDescriptor) => string): string => {
...
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.