Skip to content

Commit ef43855

Browse files
authored
fix(Fbo): missing useImperativeHandle (#2478)
* missing useImperativeHandle + story * revert story
1 parent 050b15a commit ef43855

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/Fbo.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import * as THREE from 'three'
33
import { useThree } from '@react-three/fiber'
4-
import { forwardRef } from 'react'
4+
import { forwardRef, useImperativeHandle } from 'react'
55

66
type WebGLRenderTargetCtorParams = ConstructorParameters<typeof THREE.WebGLRenderTarget>
77
type WebGLRenderTargetOptions = WebGLRenderTargetCtorParams[2]
@@ -67,12 +67,14 @@ type Fbo = ReturnType<typeof useFBO>
6767

6868
export type FboProps = {
6969
children?: (target: Fbo) => React.ReactNode
70-
width: UseFBOParams[0]
71-
height: UseFBOParams[1]
70+
width?: UseFBOParams[0]
71+
height?: UseFBOParams[1]
7272
} & FBOSettings
7373

7474
export const Fbo = /* @__PURE__ */ forwardRef<Fbo, FboProps>(({ children, width, height, ...settings }, fref) => {
7575
const target = useFBO(width, height, settings)
7676

77+
useImperativeHandle(fref, () => target, [target]) // expose target through ref
78+
7779
return <>{children?.(target)}</>
7880
})

0 commit comments

Comments
 (0)