Move parts creation outside component function
This commit is contained in:
parent
1b6a19befe
commit
8571b544e6
|
|
@ -297,14 +297,14 @@ export function define(nameOrDef: string | TagDef, defIfNamed?: TagDef) {
|
|||
|
||||
const currentProps: Record<string, any> = {}
|
||||
const Root = makeComponent(name, def, currentProps)
|
||||
const parts: Record<string, Function> = { Root }
|
||||
|
||||
for (const [part] of Object.entries(def.parts ?? {}))
|
||||
parts[part] = makeComponent(name, def, currentProps, part)
|
||||
|
||||
const component = (props: Record<string, any>) => {
|
||||
for (const key in currentProps) delete currentProps[key]
|
||||
Object.assign(currentProps, props)
|
||||
const parts: Record<string, Function> = { Root }
|
||||
|
||||
for (const [part] of Object.entries(def.parts ?? {}))
|
||||
parts[part] = makeComponent(name, def, props, part)
|
||||
|
||||
return def.render?.({ props, parts }) ?? <Root {...props}>{props.children}</Root>
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user