-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: react-router import in gatsby spa to match the docs
- Loading branch information
1 parent
b2a2c58
commit f6480bb
Showing
6 changed files
with
36 additions
and
132 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
examples/gatsby/gatsby-spa/src/pages/StudioExperiencePage.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useFetchBySlug, ExperienceRoot } from '@contentful/experiences-sdk-react'; | ||
import { PageProps } from 'gatsby'; | ||
import React from 'react'; | ||
import { useContentfulClient } from '../../utils/useContentfulClient'; | ||
|
||
type PathParams = { | ||
locale: string; | ||
slug: string, | ||
isPreviewString: string; | ||
}; | ||
|
||
const experienceTypeId = process.env.GATSBY_CTFL_EXPERIENCE_TYPE || ''; | ||
|
||
export default function StudioExperiencePage(pageProps: PageProps) { | ||
const { locale = 'en-US', slug = 'home-page', } = pageProps.params as PathParams; | ||
const isPreview = new URL(pageProps.location.href).searchParams.get('isPreview') === 'true'; | ||
const { client } = useContentfulClient({ isPreview }); | ||
|
||
const { experience, error, isLoading } = useFetchBySlug({ | ||
slug, | ||
localeCode: locale, | ||
client, | ||
experienceTypeId, | ||
}); | ||
|
||
if (isLoading) return <div>Loading...</div>; | ||
if (error) return <div>{error.message}</div>; | ||
|
||
return <ExperienceRoot experience={experience} locale={locale} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters