Skip to content

Commit

Permalink
Merge pull request #83 from vikejs/phonzammi/fix-error-page
Browse files Browse the repository at this point in the history
fix: use `usePageContext()` for error page of all examples
  • Loading branch information
brillout authored Feb 5, 2024
2 parents ec75ace + bf2e1ea commit 0601774
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions examples/basic/pages/_error/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export default Page

import React from 'react'
import { usePageContext } from 'vike-react/usePageContext'

function Page({ is404, errorInfo }: { is404: boolean; errorInfo?: string }) {
function Page() {
const { is404 } = usePageContext()
if (is404) {
return (
<>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
<p>{errorInfo}</p>
</>
)
} else {
Expand Down
5 changes: 3 additions & 2 deletions examples/react-query/pages/_error/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export default Page

import React from 'react'
import { usePageContext } from 'vike-react/usePageContext'

function Page({ is404, errorInfo }: { is404: boolean; errorInfo?: string }) {
function Page() {
const { is404 } = usePageContext()
if (is404) {
return (
<>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
<p>{errorInfo}</p>
</>
)
} else {
Expand Down
5 changes: 3 additions & 2 deletions examples/ssr-spa/pages/_error/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export default Page

import React from 'react'
import { usePageContext } from 'vike-react/usePageContext'

function Page({ is404, errorInfo }: { is404: boolean; errorInfo?: string }) {
function Page() {
const { is404 } = usePageContext()
if (is404) {
return (
<>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
<p>{errorInfo}</p>
</>
)
} else {
Expand Down
5 changes: 3 additions & 2 deletions examples/streaming/pages/_error/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export default Page

import React from 'react'
import { usePageContext } from 'vike-react/usePageContext'

function Page({ is404, errorInfo }: { is404: boolean; errorInfo?: string }) {
function Page() {
const { is404 } = usePageContext()
if (is404) {
return (
<>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
<p>{errorInfo}</p>
</>
)
} else {
Expand Down

0 comments on commit 0601774

Please sign in to comment.