File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,19 @@ export function NoSSR({
1313 return < > { state } </ > ;
1414}
1515
16+ export class ClientOnlyError extends Error {
17+ constructor ( ) {
18+ super ( "client only" ) ;
19+ }
20+ }
21+
1622export function lazy < T > (
1723 importFunc : ( ) => Promise < { default : React . ComponentType < T > } >
1824) : React . ComponentType < T > {
1925 const LazyComponent = oldLazy ( importFunc ) ;
2026 return ( props : any ) => {
2127 if ( typeof window === "undefined" ) {
22- throw new Error ( "client only" ) ;
28+ throw new ClientOnlyError ( ) ;
2329 }
2430 return < LazyComponent { ...props } /> ;
2531 } ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { NJSON } from "next-json";
33import { statSync } from "node:fs" ;
44import { join , relative } from "node:path" ;
55import { renderToReadableStream } from "react-dom/server" ;
6+ import { ClientOnlyError } from "./client" ;
67
78export class StaticRouters {
89 readonly server : FileSystemRouter ;
@@ -41,6 +42,7 @@ export class StaticRouters {
4142 bootstrapModules,
4243 context,
4344 onError = ( error , errorInfo ) => {
45+ if ( error instanceof ClientOnlyError ) return ;
4446 console . error ( error , errorInfo ) ;
4547 } ,
4648 } : {
You can’t perform that action at this time.
0 commit comments