Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

🤬 fixed a few other hydration errors

Blue Mousec573f0bab825
diff --git a/app/App.tsx b/app/App.tsx
index 1e9c3d213..7eff688cb 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -24,6 +24,7 @@ import sagaActions from 'redux/sagas/actions'
import { errorsActions } from 'redux/reducers/errors'
import { alertsActions } from 'redux/reducers/alerts'
import { StateType, useAppDispatch } from 'redux/store'
+import { isBrowser } from 'redux/constants'
import routesPath from 'routesPath'
import { getPageMeta } from 'utils/server'
@@ -79,12 +80,14 @@ const App: React.FC<IApp> = ({ ssrTheme, ssrAuthenticated }) => {
const { t } = useTranslation('common')
const alert = useAlert()
const {
- loading, authenticated,
+ loading,
} = useSelector((state: StateType) => state.auth)
+ const reduxAuthenticated = useSelector((state: StateType) => state.auth.authenticated)
const { error } = useSelector((state: StateType) => state.errors)
const { message, type } = useSelector((state: StateType) => state.alerts)
const accessToken = getAccessToken()
const refreshToken = getRefreshToken()
+ const authenticated = isBrowser ? reduxAuthenticated : ssrAuthenticated
useEffect(() => {
(async () => {
@@ -137,9 +140,9 @@ const App: React.FC<IApp> = ({ ssrTheme, ssrAuthenticated }) => {
return (
// eslint-disable-next-line react/jsx-no-useless-fragment
<Suspense fallback={<></>}>
- {pathname !== routesPath.main && (
+ {/* {pathname !== routesPath.main && (
<Header ssrTheme={ssrTheme} ssrAuthenticated={ssrAuthenticated} />
- )}
+ )} */}
{/* @ts-ignore */}
<ScrollToTop>
<Selfhosted>
@@ -148,7 +151,7 @@ const App: React.FC<IApp> = ({ ssrTheme, ssrAuthenticated }) => {
</Suspense>
</Selfhosted>
</ScrollToTop>
- <Footer minimal={isMinimalFooter} authenticated={authenticated} />
+ {/* <Footer minimal={isMinimalFooter} authenticated={authenticated} /> */}
</Suspense>
)
}
diff --git a/app/pages/Billing/index.tsx b/app/pages/Billing/index.tsx
index 8e54027af..9e3ec6d7d 100644
--- a/app/pages/Billing/index.tsx
+++ b/app/pages/Billing/index.tsx
@@ -12,7 +12,7 @@ import { ExclamationTriangleIcon, InformationCircleIcon } from '@heroicons/react
import _round from 'lodash/round'
import {
- isSelfhosted, PADDLE_JS_URL, PADDLE_VENDOR_ID, CONTACT_EMAIL, paddleLanguageMapping,
+ isSelfhosted, PADDLE_JS_URL, PADDLE_VENDOR_ID, CONTACT_EMAIL, paddleLanguageMapping, isBrowser,
} from 'redux/constants'
import { loadScript } from 'utils/generic'
import { useAppDispatch, StateType } from 'redux/store'
@@ -27,7 +27,11 @@ import Pricing from '../MainPage/Pricing'
dayjs.extend(utc)
dayjs.extend(duration)
-const Billing = (): JSX.Element => {
+interface IBilling {
+ ssrAuthenticated: boolean,
+}
+
+const Billing: React.FC<IBilling> = ({ ssrAuthenticated }): JSX.Element => {
const [isCancelSubModalOpened, setIsCancelSubModalOpened] = useState<boolean>(false)
const { metainfo, usageinfo } = useSelector((state: StateType) => state.ui.misc)
const { user }: {
@@ -35,6 +39,7 @@ const Billing = (): JSX.Element => {
} = useSelector((state: StateType) => state.auth)
const { theme } = useSelector((state: StateType) => state.ui.theme)
const paddleLoaded = useSelector((state: StateType) => state.ui.misc.paddleLoaded)
+ const reduxAuthenticated = useSelector((state: StateType) => state.auth.authenticated)
const dispatch = useDispatch()
const _dispatch = useAppDispatch()
const { t, i18n: { language } }: {
@@ -45,6 +50,7 @@ const Billing = (): JSX.Element => {
language: string,
},
} = useTranslation('common')
+ const authenticated = isBrowser ? reduxAuthenticated : ssrAuthenticated
const {
nextBillDate, planCode, subUpdateURL, trialEndDate, timeFormat, cancellationEffectiveDate, subCancelURL, maxEventsCount,
} = user
@@ -240,7 +246,7 @@ const Billing = (): JSX.Element => {
</span>
</div>
)}
- <Pricing t={t} language={language} />
+ <Pricing authenticated={authenticated} t={t} language={language} />
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight mt-10'>
<Trans
// @ts-ignore
diff --git a/app/pages/MainPage/Pricing.tsx b/app/pages/MainPage/Pricing.tsx
index d36276f01..948ad861e 100644
--- a/app/pages/MainPage/Pricing.tsx
+++ b/app/pages/MainPage/Pricing.tsx
@@ -270,11 +270,12 @@ const PricingItem = ({
interface IPricing {
t: (key: string) => string,
language: string,
+ authenticated: boolean,
}
-const Pricing = ({ t, language }: IPricing) => {
+const Pricing = ({ t, language, authenticated }: IPricing) => {
const dispatch: AppDispatch = useDispatch()
- const { authenticated, user } = useSelector((state: StateType) => state.auth)
+ const { user } = useSelector((state: StateType) => state.auth)
const { theme } = useSelector((state: StateType) => state.ui.theme)
const { paddle, metainfo } = useSelector((state: StateType) => state.ui.misc)
const { lastEvent } = paddle
diff --git a/app/pages/MainPage/index.tsx b/app/pages/MainPage/index.tsx
index a3232fb35..4aebb1881 100644
--- a/app/pages/MainPage/index.tsx
+++ b/app/pages/MainPage/index.tsx
@@ -551,7 +551,7 @@ const Main: React.FC<IMain> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
</div>
</div>
{/* end Marketplace and extension features */}
- <Pricing t={t} language={language} />
+ <Pricing authenticated={authenticated} t={t} language={language} />
{/* section: Why use Swetrix when there is .... */}
<div className='overflow-hidden'>
diff --git a/app/root.tsx b/app/root.tsx
index 9926d027b..e74a35054 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -10,7 +10,6 @@ import {
useLoaderData,
ScrollRestoration,
} from '@remix-run/react'
-import { ClientOnly } from 'remix-utils'
import { store } from 'redux/store'
import { whitelist, isBrowser } from 'redux/constants'
import { Provider } from 'react-redux'
@@ -187,19 +186,12 @@ export default function App() {
/>
</AlertProvider>
</Provider>
- <ClientOnly>
- {() => (
- <ScrollRestoration />
- )}
- </ClientOnly>
- {/* <ScrollRestoration /> */}
+ <ScrollRestoration />
<Scripts />
- {/* <ClientOnly>
- {() => (
- <Scripts />
- )}
- </ClientOnly> */}
<LiveReload />
+ {!isBrowser && (
+ <div id='__react-alert__' />
+ )}
</body>
</html>
)
diff --git a/app/routes/billing.tsx b/app/routes/billing.tsx
index a26c33a94..351bd349a 100644
--- a/app/routes/billing.tsx
+++ b/app/routes/billing.tsx
@@ -1,10 +1,22 @@
-import Billing from 'pages/Billing'
+import type { LoaderArgs } from '@remix-run/node'
+import { useLoaderData } from '@remix-run/react'
+import { json } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
+import Billing from 'pages/Billing'
+import { isAuthenticated } from 'utils/server'
export const sitemap: SitemapFunction = () => ({
exclude: true,
})
+export async function loader({ request }: LoaderArgs) {
+ const isAuth = isAuthenticated(request)
+
+ return json({ isAuth })
+}
+
export default function Index() {
- return <Billing />
+ const { isAuth } = useLoaderData<typeof loader>()
+
+ return <Billing ssrAuthenticated={isAuth} />
}