UNPKG

@builder.io/mitosis

Version:

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

18 lines (17 loc) 729 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renderMountHook = void 0; const lodash_1 = require("lodash"); const on_mount_1 = require("../helpers/on-mount"); const render_update_hooks_1 = require("./render-update-hooks"); function shouldRenderMountHook(json) { return json.hooks.onMount.length > 0 || (0, render_update_hooks_1.hasWatchHooks)(json); } exports.renderMountHook = (0, lodash_1.curry)((json, objectString) => { return shouldRenderMountHook(json) ? objectString.replace(/(?:,)?(\s*)(}\s*)$/, `, init() { ${(0, render_update_hooks_1.renderWatchHooks)(json)} ${(0, on_mount_1.stringifySingleScopeOnMount)(json)} }$1$2`) : objectString; });