diff --git a/package-lock.json b/package-lock.json index 481e367fba..93d2831988 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "react-datepicker": "^7.3.0", "react-dom": "^17.0.2", "react-google-recaptcha": "^3.1.0", - "react-i18next": "^11.18.1", + "react-i18next": "^12.3.1", "react-icons": "^5.2.1", "react-infinite-scroll-component": "^6.1.0", "react-multi-carousel": "^2.8.5", @@ -20519,11 +20519,11 @@ } }, "node_modules/react-i18next": { - "version": "11.18.6", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-11.18.6.tgz", - "integrity": "sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==", + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-12.3.1.tgz", + "integrity": "sha512-5v8E2XjZDFzK7K87eSwC7AJcAkcLt5xYZ4+yTPDAW1i7C93oOY1dnr4BaQM7un4Hm+GmghuiPvevWwlca5PwDA==", "dependencies": { - "@babel/runtime": "^7.14.5", + "@babel/runtime": "^7.20.6", "html-parse-stringify": "^3.0.1" }, "peerDependencies": { @@ -39656,11 +39656,11 @@ } }, "react-i18next": { - "version": "11.18.6", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-11.18.6.tgz", - "integrity": "sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==", + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-12.3.1.tgz", + "integrity": "sha512-5v8E2XjZDFzK7K87eSwC7AJcAkcLt5xYZ4+yTPDAW1i7C93oOY1dnr4BaQM7un4Hm+GmghuiPvevWwlca5PwDA==", "requires": { - "@babel/runtime": "^7.14.5", + "@babel/runtime": "^7.20.6", "html-parse-stringify": "^3.0.1" } }, diff --git a/package.json b/package.json index fc27d359fd..5b47ed1137 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "react-datepicker": "^7.3.0", "react-dom": "^17.0.2", "react-google-recaptcha": "^3.1.0", - "react-i18next": "^11.18.1", + "react-i18next": "^12.3.1", "react-icons": "^5.2.1", "react-infinite-scroll-component": "^6.1.0", "react-multi-carousel": "^2.8.5", diff --git a/src/utils/errorHandler.test.tsx b/src/utils/errorHandler.test.tsx index 1ca42441ab..45f46e6389 100644 --- a/src/utils/errorHandler.test.tsx +++ b/src/utils/errorHandler.test.tsx @@ -1,4 +1,5 @@ -import type { TFunction } from 'react-i18next'; +type TFunction = (key: string, options?: Record) => string; + import { errorHandler } from './errorHandler'; import { toast } from 'react-toastify'; @@ -9,8 +10,9 @@ jest.mock('react-toastify', () => ({ })); describe('Test if errorHandler is working properly', () => { - const t: TFunction<'translation', string> = (key: string) => key; - const tErrors: TFunction<'errors', string> = (key: string) => key; + const t: TFunction = (key: string) => key; + const tErrors: TFunction = (key: string, options?: Record) => + key; it('should call toast.error with the correct message if error message is "Failed to fetch"', () => { const error = new Error('Failed to fetch'); diff --git a/src/utils/errorHandler.tsx b/src/utils/errorHandler.tsx index cdc6ebd5c6..d65bb5f746 100644 --- a/src/utils/errorHandler.tsx +++ b/src/utils/errorHandler.tsx @@ -1,4 +1,5 @@ -import type { TFunction } from 'react-i18next'; +type TFunction = (key: string, options?: Record) => string; + import { toast } from 'react-toastify'; import i18n from './i18n'; /** @@ -7,10 +8,7 @@ import i18n from './i18n'; If the error is due to the Talawa API being unavailable, it displays a custom message. */ export const errorHandler = (a: unknown, error: unknown): void => { - const tErrors = i18n.getFixedT( - null, - 'errors', - ) as unknown as TFunction; + const tErrors: TFunction = i18n.getFixedT(null, 'errors'); if (error instanceof Error) { switch (error.message) { case 'Failed to fetch':