UNPKG

@builder.io/mitosis

Version:

Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io

26 lines (25 loc) 692 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stringifySingleScopeOnMount = void 0; /** * Helper for frameworks where all `onMount()`s must share a single scope. */ const stringifySingleScopeOnMount = (json) => { const hooks = json.hooks.onMount; if (hooks.length === 0) return ''; if (hooks.length === 1) { return hooks[0].code; } return hooks .map((hook, i) => { const hookFnName = `onMountHook_${i}`; return ` const ${hookFnName} = () => { ${hook.code} } ${hookFnName}();`; }) .join(''); }; exports.stringifySingleScopeOnMount = stringifySingleScopeOnMount;