11import type { VNode , VNodeData } from 'vue'
2+ import Vue from 'vue'
23import {
34 checkKeyIsVueDirective ,
45 checkIsHTMLElement ,
@@ -22,6 +23,7 @@ import { ConfigType, TagType } from './type'
2223import { getCurrentInstance } from './runtime'
2324
2425const V_BIND_REGEXP = / ^ v ( - b | B ) i n d : /
26+ let _jsxsId = 0
2527
2628// Reference:
2729// https://cn.vuejs.org/v2/guide/render-function.html
@@ -144,11 +146,21 @@ const jsx = function (
144146 const children = isArray ( config . children ) ? config . children : [ config . children ]
145147
146148 // Check if it is JSXS function.
149+ // JSXS function must be wrapped into a Vue component, and in order to
150+ // avoid re-creating component, register it as a global component, and
151+ // next time it will be taken out from Vue.
147152 const isJsxsFunc = typeof tag === 'function' && isUndefined ( ( tag as any ) . cid )
148153 if ( isJsxsFunc ) {
149- return h ( {
150- render : tag as any
151- } , vNodeData , children )
154+ // @ts -ignore
155+ let jsxsId = tag . __jsxs_id__
156+ if ( ! jsxsId ) {
157+ jsxsId = 'jsxs-comp-' + _jsxsId ++
158+ // @ts -ignore
159+ tag . __jsxs_id__ = jsxsId
160+ // @ts -ignore
161+ Vue . component ( jsxsId , { render : tag } )
162+ }
163+ return h ( Vue . component ( jsxsId ) , vNodeData , children )
152164 }
153165
154166 return h ( tag , vNodeData , children )
0 commit comments