Skip to content

Commit 254a715

Browse files
fix: don't no-op primitive prepare
1 parent 090e497 commit 254a715

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/fiber/src/core/reconciler.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ function handleContainerEffects(parent: Instance, child: Instance, beforeChild?:
9696
if (!parent.parent && parent.object !== state.scene) return
9797

9898
// Create & link object on first run
99-
if (!child.object?.__r3f) {
100-
if (!child.object) {
101-
// Get target from catalogue
102-
const name = `${child.type[0].toUpperCase()}${child.type.slice(1)}`
103-
const target = catalogue[name]
104-
105-
// Create object
106-
child.object = child.props.object ?? new target(...(child.props.args ?? []))
107-
}
99+
if (!child.object) {
100+
// Get target from catalogue
101+
const name = `${child.type[0].toUpperCase()}${child.type.slice(1)}`
102+
const target = catalogue[name]
103+
104+
// Create object
105+
child.object = child.props.object ?? new target(...(child.props.args ?? []))
108106
child.object.__r3f = child
109107

110108
// Set initial props

packages/fiber/src/core/utils.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ export function prepare<T = any>(target: T, root: RootStore, type: string, props
221221
handlers: {},
222222
isHidden: false,
223223
}
224-
if (object) object.__r3f = instance
224+
if (object) {
225+
object.__r3f = instance
226+
if (type) applyProps(object, instance.props)
227+
}
225228
}
226229

227230
return instance

0 commit comments

Comments
 (0)