From 4a07ae1e121c5851d0f0737a2b6a3d95cc57bf3d Mon Sep 17 00:00:00 2001 From: Illia Kovalenko <23364749+illiakovalenko@users.noreply.github.com> Date: Tue, 27 Apr 2021 10:18:03 +0300 Subject: [PATCH] [sitecore-jss-nextjs] Links inside RichText control cause page to be loaded twice (#659) * Fix internal links initialization * Add doc --- docs/data/routes/release-notes/en.md | 1 + packages/sitecore-jss-nextjs/src/components/RichText.tsx | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/data/routes/release-notes/en.md b/docs/data/routes/release-notes/en.md index 75e149b348..e1f6899916 100644 --- a/docs/data/routes/release-notes/en.md +++ b/docs/data/routes/release-notes/en.md @@ -26,6 +26,7 @@ There are [migration instructions](/upgrade-guides/18.0) from JSS 16-based appli ### Bug Fixes +* [PR #659](https://github.com/Sitecore/jss/pull/659) [sitecore-jss-nextjs] Links inside RichText control cause page to be loaded twice * [PR #624](https://github.com/Sitecore/jss/pull/624): * [sitecore-jss-react-native] [Image] Pass Object `style` type for `SvgUrI` instead of Array. * [sitecore-jss-react-native] [Date] Always render `` if `editable` is provided. diff --git a/packages/sitecore-jss-nextjs/src/components/RichText.tsx b/packages/sitecore-jss-nextjs/src/components/RichText.tsx index 79010e87f1..f69d297a19 100644 --- a/packages/sitecore-jss-nextjs/src/components/RichText.tsx +++ b/packages/sitecore-jss-nextjs/src/components/RichText.tsx @@ -30,7 +30,7 @@ export const RichText = (props: RichTextProps): JSX.Element => { if (hasText && !isEditing) { initializeLinks(); } - }); + }, []); const routeHandler = (ev: MouseEvent) => { if (!ev.target) return; @@ -56,7 +56,6 @@ export const RichText = (props: RichTextProps): JSX.Element => { prefetched[link.pathname] = true; } - link.removeEventListener('click', routeHandler, false); link.addEventListener('click', routeHandler, false); }); };