@@ -2,9 +2,8 @@ import { forwardRef, ReactNode, RefAttributes, useEffect, useMemo, useRef } from
2
2
import { Object3D } from 'three'
3
3
import { ParentProvider , useParent } from './context.js'
4
4
import { AddHandlers , R3FEventMap , usePropertySignals } from './utils.js'
5
- import { createContent , initialize , Subscriptions , unsubscribeSubscriptions } from '@pmndrs/uikit/internals'
6
5
import { ComponentInternals , useComponentInternals } from './ref.js'
7
- import { ContentProperties as BaseContentProperties } from '../../ uikit/dist/components/content.js '
6
+ import { ContentProperties as BaseContentProperties , createContentState , setupContent } from '@pmndrs/ uikit/internals '
8
7
9
8
export type ContentProperties = {
10
9
name ?: string
@@ -21,12 +20,11 @@ export const Content: (props: ContentProperties & RefAttributes<ContentRef>) =>
21
20
const propertySignals = usePropertySignals ( properties )
22
21
const internals = useMemo (
23
22
( ) =>
24
- createContent < R3FEventMap > (
23
+ createContentState < R3FEventMap > (
25
24
parent ,
26
25
propertySignals . style ,
27
26
propertySignals . properties ,
28
27
propertySignals . default ,
29
- outerRef ,
30
28
innerRef ,
31
29
) ,
32
30
[ parent , propertySignals ] ,
@@ -35,10 +33,21 @@ export const Content: (props: ContentProperties & RefAttributes<ContentRef>) =>
35
33
internals . interactionPanel . name = properties . name ?? ''
36
34
37
35
useEffect ( ( ) => {
38
- const subscriptions : Subscriptions = [ ]
39
- initialize ( internals . initializers , subscriptions )
40
- return ( ) => unsubscribeSubscriptions ( subscriptions )
41
- } , [ internals ] )
36
+ if ( outerRef . current == null || innerRef . current == null ) {
37
+ return
38
+ }
39
+ const abortController = new AbortController ( )
40
+ setupContent < R3FEventMap > (
41
+ internals ,
42
+ parent ,
43
+ propertySignals . style ,
44
+ propertySignals . properties ,
45
+ outerRef . current ,
46
+ innerRef . current ,
47
+ abortController . signal ,
48
+ )
49
+ return ( ) => abortController . abort ( )
50
+ } , [ internals , parent , propertySignals ] )
42
51
43
52
useComponentInternals ( ref , parent . root . pixelSize , propertySignals . style , internals , internals . interactionPanel )
44
53
0 commit comments