Skip to content

Commit

Permalink
[BOT]maryia/BOT-2108/refactor: Remove dangerouslySetInnerHTML (binary…
Browse files Browse the repository at this point in the history
…-com#16514)

* refactor: Remove dangerouslySetInnerHTML

* chore: Empty-Commit

* chore: Empty-Commit
  • Loading branch information
maryia-matskevich-deriv committed Aug 20, 2024
1 parent ce39c61 commit 5f6c23b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/bot-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"react-router-dom": "^5.2.0",
"react-toastify": "^9.1.3",
"react-transition-group": "4.4.2",
"html-react-parser": "5.1.12",
"yup": "^0.32.11"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames';
import { Text } from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
import { TStrategyDescription } from '../types';
import parse from 'html-react-parser';

const StrategyDescription = observer(({ item, font_size }: TStrategyDescription) => {
const { ui } = useStore();
Expand All @@ -13,23 +14,29 @@ const StrategyDescription = observer(({ item, font_size }: TStrategyDescription)
const class_names = classNames(`qs__description__content ${class_name}`);
return (
<>
{item?.content?.map((text: string) => (
<div className={class_names} key={text}>
<Text size={font_size} dangerouslySetInnerHTML={{ __html: text }} />
</div>
))}
{item?.content?.map((text: string) => {
const parsed_text = parse(text);
return (
<div className={class_names} key={text}>
<Text size={font_size}>{parsed_text}</Text>
</div>
);
})}
</>
);
}
case 'text_italic': {
const class_names = classNames(`qs__description__content italic ${class_name}`);
return (
<>
{item?.content?.map((text: string) => (
<div className={class_names} key={text}>
<Text size={font_size} dangerouslySetInnerHTML={{ __html: text }} />
</div>
))}
{item?.content?.map((text: string) => {
const parsed_text = parse(text);
return (
<div className={class_names} key={text}>
<Text size={font_size}>{parsed_text}</Text>
</div>
);
})}
</>
);
}
Expand Down
8 changes: 5 additions & 3 deletions packages/bot-web-ui/src/pages/tutorials/faq-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Localize } from '@deriv/translations';
import { DBOT_TABS } from 'Constants/bot-contents';
import { useDBotStore } from 'Stores/useDBotStore';
import { TDescription } from '../tutorials.types';
import parse from 'html-react-parser';

type TFAQContent = {
faq_list: TFAQList[];
Expand All @@ -19,7 +20,7 @@ type TFAQList = {

const FAQ = ({ type, content = '', src, imageclass, is_mobile }: TDescription) => {
if (type === 'image') return <img src={src} className={imageclass} />;

const parsed_content = parse(content);
return (
<Text
as='p'
Expand All @@ -28,8 +29,9 @@ const FAQ = ({ type, content = '', src, imageclass, is_mobile }: TDescription) =
className='faq__description'
weight='normal'
key={content}
dangerouslySetInnerHTML={{ __html: content }}
/>
>
{parsed_content}
</Text>
);
};

Expand Down

0 comments on commit 5f6c23b

Please sign in to comment.