-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fragment initial load in React Framework (#1173)
- Loading branch information
1 parent
386fc4c
commit 09eddb4
Showing
5 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
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,19 @@ | ||
import { graphql, useFragment, type SponsorInfo } from '$houdini' | ||
|
||
type Props = { | ||
sponsor: SponsorInfo | ||
} | ||
|
||
export default function SponsorSummary(props: Props) { | ||
const data = useFragment( | ||
props.sponsor, | ||
graphql(` | ||
fragment SponsorInfo on Sponsor { | ||
name | ||
avatarUrl | ||
} | ||
`) | ||
) | ||
|
||
return <div>{data?.name}</div> | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
query SponsorList { | ||
sponsors { | ||
name | ||
...SponsorInfo | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,21 @@ | ||
import { cache } from '$houdini/runtime' | ||
import SponsorInfo from '~/components/SponsorInfo' | ||
|
||
import type { PageProps } from './$types' | ||
|
||
if (globalThis.window) { | ||
// @ts-ignore | ||
window.cache = cache | ||
} | ||
|
||
export default function ({ SponsorList }: PageProps) { | ||
return <div>{JSON.stringify(SponsorList)}</div> | ||
return ( | ||
<div> | ||
{SponsorList.sponsors.map((sponsor) => ( | ||
<div key={sponsor.name}> | ||
<SponsorInfo sponsor={sponsor} /> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} |
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
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