Fix react-intl missing translation error (#882)

* Improve error handling

* Remove unused import
This commit is contained in:
Dominik Żegleń 2020-12-01 18:18:58 +01:00 committed by GitHub
parent 09625eb486
commit f97ddd0128
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
import useLocalStorage from "@saleor/hooks/useLocalStorage";
import React from "react";
import { IntlProvider, MissingTranslationError } from "react-intl";
import { IntlProvider, ReactIntlErrorCode } from "react-intl";
export enum Locale {
AR = "ar",
@ -165,7 +165,7 @@ const LocaleProvider: React.FC = ({ children }) => {
locale={locale}
messages={getKeyValueJson(messages)}
onError={err => {
if (!(err instanceof MissingTranslationError)) {
if (!(err.code === ReactIntlErrorCode.MISSING_TRANSLATION)) {
console.error(err);
}
}}