Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix react toastify not displaying #98

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/language/translate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';
import get from 'lodash/get';
import sanitizeHtml from 'sanitize-html';
import TranslatorContext from './translator-context';
Expand Down Expand Up @@ -224,11 +224,12 @@ export const translate = (contentKey: string, interpolate?: any, children?: stri

if (translation.html) {
const contentArray = Array.isArray(translation.content) ? translation.content : [translation.content];
return contentArray.map((content, i) =>
const processedContent = contentArray.map((content, i) =>
content.$$typeof === REACT_ELEMENT
? { ...content, key: i }
: React.createElement('span', { key: i, dangerouslySetInnerHTML: { __html: content } })
);
return processedContent.length === 1 ? processedContent[0] : <Fragment>{processedContent}</Fragment>;
} else {
return translation.content;
}
Expand Down
Loading