Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Daydreamer-riri committed Feb 21, 2024
1 parent 4bff853 commit 1d4e033
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/client/components/ClientOnly.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ export default function ClientOnly({
const isBrowser = useIsBrowser()

if (isBrowser) {
if (
typeof children !== 'function'
&& process.env.NODE_ENV === 'development'
) {
throw new Error(`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
Current type: ${isValidElement(children) ? 'React element' : typeof children}`)
if (typeof children !== 'function' && process.env.NODE_ENV === 'development') {
throw new Error(
`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
Current type: ${isValidElement(children) ? 'React element' : typeof children}`,
)
}
return <>{children?.()}</>
}
Expand Down

0 comments on commit 1d4e033

Please sign in to comment.