Skip to content

Commit 8dffc27

Browse files
committed
Fix dangerouslysetinnerhtml
1 parent b858533 commit 8dffc27

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/components/layouts/footer/index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,35 @@ import { getIconComponentByName } from '../../../utils/icons-map';
99
*/
1010
import {isEmpty, isArray} from 'lodash';
1111
import Link from 'next/link';
12+
import { useEffect, useState } from 'react';
1213

1314
const Footer = ({footer}) => {
1415

1516
const { copyrightText, footerMenuItems, sidebarOne, sidebarTwo, socialLinks } = footer || {};
17+
const [isMounted, setMount] = useState(false);
18+
19+
20+
useEffect(() => {
21+
setMount(true);
22+
}, []);
1623

1724
return (
1825
<footer className="bg-blue-500 p-6">
1926
<div className="container mx-auto">
2027
<div className="flex flex-wrap -mx-1 overflow-hidden text-white">
21-
{/*Widget One*/}
22-
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
23-
<div dangerouslySetInnerHTML={{ __html: sanitize( sidebarOne ) }}/>
24-
</div>
25-
{/*Widget Two*/}
26-
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
27-
<div dangerouslySetInnerHTML={{ __html: sanitize( sidebarTwo ) }}/>
28-
</div>
28+
29+
{ isMounted ? (
30+
<>
31+
{/*Widget One*/}
32+
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
33+
<div dangerouslySetInnerHTML={{ __html: sanitize( sidebarOne ) }}/>
34+
</div>
35+
{/*Widget Two*/}
36+
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">
37+
<div dangerouslySetInnerHTML={{ __html: sanitize( sidebarTwo ) }}/>
38+
</div>
39+
</>
40+
) : null}
2941

3042
{/* Footer Menus*/}
3143
<div className="my-1 px-1 w-full overflow-hidden sm:w-full lg:w-1/2 xl:w-1/3">

0 commit comments

Comments
 (0)