forked from opentiny/tiny-vue
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:
parent
16169ff41c
commit
8b29e63a79
|
@ -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,
|
||||
|
|
|
@ -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 ''
|
||||
}
|
Loading…
Reference in New Issue