Skip to content

Commit 29db01a

Browse files
committed
move context to the feedback widget component to keep the base layout server rendered
1 parent 922a81c commit 29db01a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/components/FeedbackWidget/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client"
22

3+
import { useContext } from "react"
34
import { MdClose } from "react-icons/md"
45

56
import { Button } from "@/components/ui/buttons/Button"
@@ -14,9 +15,11 @@ import {
1415
import FixedDot from "./FixedDot"
1516
import { useFeedbackWidget } from "./useFeedbackWidget"
1617

18+
import { FeedbackWidgetContext } from "@/contexts/FeedbackWidgetContext"
1719
import { useTranslation } from "@/hooks/useTranslation"
1820

1921
const FeedbackWidget = () => {
22+
const { showFeedbackWidget } = useContext(FeedbackWidgetContext)
2023
const { t } = useTranslation("common")
2124
const {
2225
offsetBottom,
@@ -29,6 +32,9 @@ const FeedbackWidget = () => {
2932
isExpanded,
3033
isOpen,
3134
} = useFeedbackWidget()
35+
36+
if (!showFeedbackWidget) return null
37+
3238
return (
3339
<>
3440
<Popover

src/components/ListenToPlayer/ListenToPlayer.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const BaseLayout: StoryObj<typeof meta> = {
3939
<ListenToPlayer slug="/eth" />
4040
</div>
4141
),
42-
contentIsOutdated: false,
43-
contentNotTranslated: false,
42+
// contentIsOutdated: false,
43+
// contentNotTranslated: false,
4444
lastDeployLocaleTimestamp: "May 14, 2021",
4545
},
4646
}

src/components/ListenToPlayer/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import { useContext, useEffect, useState } from "react"
24
import { Howl } from "howler"
35
import { Portal } from "@radix-ui/react-portal"

src/layouts/BaseLayout.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// import { join } from "path"
2-
import { useContext } from "react"
32
import dynamic from "next/dynamic"
43

54
import type { Root } from "@/lib/types"
@@ -8,8 +7,6 @@ import Footer from "@/components/Footer"
87
import Nav from "@/components/Nav"
98
import { SkipLink } from "@/components/SkipLink"
109

11-
import { FeedbackWidgetContext } from "@/contexts/FeedbackWidgetContext"
12-
1310
// import TranslationBanner from "@/components/TranslationBanner"
1411
// import TranslationBannerLegal from "@/components/TranslationBannerLegal"
1512
// import { toPosixPath } from "@/lib/utils/relativePath"
@@ -25,7 +22,6 @@ export const BaseLayout = ({
2522
// contentNotTranslated,
2623
lastDeployLocaleTimestamp,
2724
}: Root) => {
28-
const { showFeedbackWidget } = useContext(FeedbackWidgetContext)
2925
// const { locale, asPath } = useRouter()
3026

3127
// const CONTRIBUTING = "/contributing/"
@@ -79,7 +75,7 @@ export const BaseLayout = ({
7975
* layout on initial load.
8076
*/}
8177

82-
{showFeedbackWidget && <FeedbackWidget />}
78+
<FeedbackWidget />
8379
</>
8480
)
8581
}

0 commit comments

Comments
 (0)