@@ -97,7 +97,7 @@ function isRiveFile(source: ViewModelSource | null): source is RiveFile {
9797}
9898
9999type CreateInstanceResult = {
100- instance : ViewModelInstance | null ;
100+ instance : ViewModelInstance | null | undefined ;
101101 needsDispose : boolean ;
102102 error ?: string ;
103103} ;
@@ -110,7 +110,7 @@ function createInstance(
110110 useNew : boolean
111111) : CreateInstanceResult {
112112 if ( ! source ) {
113- return { instance : null , needsDispose : false } ;
113+ return { instance : undefined , needsDispose : false } ;
114114 }
115115
116116 if ( isRiveViewRef ( source ) ) {
@@ -179,7 +179,8 @@ function createInstance(
179179export type UseViewModelInstanceResult =
180180 | { instance : ViewModelInstance ; error : null }
181181 | { instance : null ; error : Error }
182- | { instance : null ; error : null } ;
182+ | { instance : null ; error : null }
183+ | { instance : undefined ; error : null } ;
183184
184185/**
185186 * Hook for getting a ViewModelInstance from a RiveFile, ViewModel, or RiveViewRef.
@@ -266,7 +267,9 @@ export type UseViewModelInstanceResult =
266267export function useViewModelInstance (
267268 source : RiveFile ,
268269 params : UseViewModelInstanceFileParams & { required : true }
269- ) : { instance : ViewModelInstance ; error : null } ;
270+ ) :
271+ | { instance : ViewModelInstance ; error : null }
272+ | { instance : undefined ; error : null } ;
270273export function useViewModelInstance (
271274 source : RiveFile | null ,
272275 params ?: UseViewModelInstanceFileParams
@@ -276,7 +279,9 @@ export function useViewModelInstance(
276279export function useViewModelInstance (
277280 source : ViewModel ,
278281 params : UseViewModelInstanceViewModelParams & { required : true }
279- ) : { instance : ViewModelInstance ; error : null } ;
282+ ) :
283+ | { instance : ViewModelInstance ; error : null }
284+ | { instance : undefined ; error : null } ;
280285export function useViewModelInstance (
281286 source : ViewModel | null ,
282287 params ?: UseViewModelInstanceViewModelParams
@@ -286,7 +291,9 @@ export function useViewModelInstance(
286291export function useViewModelInstance (
287292 source : RiveViewRef ,
288293 params : UseViewModelInstanceRefParams & { required : true }
289- ) : { instance : ViewModelInstance ; error : null } ;
294+ ) :
295+ | { instance : ViewModelInstance ; error : null }
296+ | { instance : undefined ; error : null } ;
290297export function useViewModelInstance (
291298 source : RiveViewRef | null ,
292299 params ?: UseViewModelInstanceRefParams
@@ -315,7 +322,7 @@ export function useViewModelInstance(
315322 const onInit = params ?. onInit ;
316323
317324 const prevInstanceRef = useRef < {
318- instance : ViewModelInstance | null ;
325+ instance : ViewModelInstance | null | undefined ;
319326 needsDispose : boolean ;
320327 } | null > ( null ) ;
321328
@@ -372,5 +379,8 @@ export function useViewModelInstance(
372379 if ( result . instance ) {
373380 return { instance : result . instance , error : null } ;
374381 }
382+ if ( result . instance === undefined ) {
383+ return { instance : undefined , error : null } ;
384+ }
375385 return { instance : null , error } ;
376386}
0 commit comments