File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 1- // TODO/soon: add deprecation warning in favor of <ClientOnly>
21// TO-DO/breaking-change: remove it
32
43export { clientOnly }
@@ -13,6 +12,7 @@ import React, {
1312 type ComponentType ,
1413 type ReactNode ,
1514} from 'react'
15+ import { assertWarning } from '../utils/assert.js'
1616
1717/**
1818 * Load and render a component only on the client-side.
@@ -22,6 +22,8 @@ import React, {
2222function clientOnly < T extends ComponentType < any > > (
2323 load : ( ) => Promise < { default : T } | T > ,
2424) : ComponentType < ComponentProps < T > & { fallback ?: ReactNode } > {
25+ assertWarning ( false , 'clientOnly() is deprecated — use <ClientOnly> https://vike.dev/ClientOnly' )
26+
2527 if ( ! globalThis . __VIKE__IS_CLIENT ) {
2628 return ( props ) => < > { props . fallback } </ >
2729 } else {
Original file line number Diff line number Diff line change @@ -2,3 +2,8 @@ export function assert(condition: unknown): asserts condition {
22 if ( condition ) return
33 throw new Error ( 'You stumbled upon a vike-react bug, reach out on GitHub.' )
44}
5+
6+ export function assertWarning ( condition : unknown , message : string ) {
7+ if ( condition ) return
8+ console . warn ( new Error ( message ) )
9+ }
You can’t perform that action at this time.
0 commit comments