feat(react): add render stack to build parent-child relationship (#770)

* feat(react): add render stack to build parent-child relationship

* feat(react): render-stack return empty string as valid react el
This commit is contained in:
Mr.栋 2023-11-13 15:11:23 +08:00 committed by GitHub
parent 16169ff41c
commit 8b29e63a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -55,7 +55,7 @@ export const useSetup = ({
// renderless 作为 setup 的结果,最后要将结果挂在 vm 上
let setupResult = useExcuteOnce(() => {
const render = typeof reactiveProps.tiny_renderless === 'function' ? reactiveProps.tiny_renderless : renderless
const { dispath, broadcast } = emitEvent(vm)
const { dispatch, broadcast } = emitEvent(vm)
const utils = {
vm,
@ -63,7 +63,7 @@ export const useSetup = ({
emit: emit(reactiveProps),
constants,
nextTick,
dispath,
dispatch,
broadcast,
t() { },
mergeClass,

View File

@ -0,0 +1,15 @@
const renderStack = []
export const getParent = () => renderStack[renderStack.length - 1] || ({})
export const getRoot = () => renderStack[0] || ({})
export const EnterStack = (props) => {
renderStack.push(props)
return ''
}
export const LeaveStack = () => {
renderStack.pop()
return ''
}