我需要在我的中间件(import { Middleware } from 'redux')逻辑中进行翻译,但我不能使用useTranslation钩子(import { useTranslation } from 'react-i18next')。您如何标准解决这种情况?
错误信息:
\nReact Hook "useTranslation" is called in function "myFunction: Middleware<{}, RootStateType>" which is neither a React function component or a custom React Hook function.\nRun Code Online (Sandbox Code Playgroud)\n我的代码(缩短):
\nimport PushNotificationIOS from '@react-native-community/push-notification-ios';\nimport { Middleware } from 'redux';\nimport { getType } from 'typesafe-actions';\n\nconst scheduleNotificationSettings = (notification: NotificationT): void => {\n PushNotificationIOS.scheduleLocalNotification({\n fireDate: notification.startDate,\n alertTitle: TRANSLATE_SOMEHOW(notification.titleKey),<--- ! HERE ! \xc2\xaf\\_(\xe2\x80\xaf\xe2\x9d\x9b\xe2\x80\xaf\xcd\x9c\xca\x96 \xef\xb8\xa1\xe2\x9d\x9b)_/\xc2\xaf\n alertBody: TRANSLATE_SOMEHOW(notification.bodyKey), <--- …Run Code Online (Sandbox Code Playgroud)