Skip to content

Commit

Permalink
fix announcement bar loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jorka committed Aug 8, 2024
1 parent aabcafe commit 99ed84b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/theme/AnnouncementBar/Content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function AnnouncementBarContent(props) {
const { announcementBar } = useThemeConfig();
const { content } = announcementBar;

const [loaded, setLoaded] = useState(false);
const [dynamicContent, setDynamicContent] = useState(content);
const [balanceLoaded, setBalanceLoaded] = useState(false);

Expand Down Expand Up @@ -68,6 +69,7 @@ export default function AnnouncementBarContent(props) {
newContent = newContent.replace(`{{${v}}}`, values[i]);
});
setDynamicContent(newContent);
setLoaded(true);
}

updateContent();
Expand All @@ -79,7 +81,9 @@ export default function AnnouncementBarContent(props) {
className={clsx(styles.content, props.className)}
// Developer provided the HTML, so assume it's safe.
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: dynamicContent }}
dangerouslySetInnerHTML={{
__html: loaded ? dynamicContent : null,
}}
/>
);
}

0 comments on commit 99ed84b

Please sign in to comment.