Skip to content

Commit

Permalink
fix: react three test renderer working also with manually managed com…
Browse files Browse the repository at this point in the history
…ponents that are not mounted via r3f
  • Loading branch information
DoctypeRosenthal committed Jan 8, 2022
1 parent c3bb106 commit e12511a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/test-renderer/src/createTestInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export class ReactThreeTestInstance<TInstance extends Object3D = Object3D> {
}

public get instance(): Object3D {
return (this._fiber as unknown) as TInstance
return this._fiber as unknown as TInstance
}

public get type(): string {
return this._fiber.type
}

public get props(): Obj {
return this._fiber.__r3f.memoizedProps
return this._fiber.__r3f?.memoizedProps ?? this._fiber
}

public get parent(): ReactThreeTestInstance | null {
Expand Down Expand Up @@ -50,7 +50,7 @@ export class ReactThreeTestInstance<TInstance extends Object3D = Object3D> {
*/
return [
...(fiber.children || []).map((fib) => wrapFiber(fib as MockInstance)),
...fiber.__r3f.objects.map((fib) => wrapFiber(fib as MockInstance)),
...(fiber.__r3f?.objects ?? []).map((fib) => wrapFiber(fib as MockInstance)),
]
} else {
return (fiber.children || []).map((fib) => wrapFiber(fib as MockInstance))
Expand Down

0 comments on commit e12511a

Please sign in to comment.